[Numpy-svn] r3884 - in trunk/numpy/lib: . tests

numpy-svn@scip... numpy-svn@scip...
Tue Jul 10 11:10:43 CDT 2007


Author: stefan
Date: 2007-07-10 11:10:25 -0500 (Tue, 10 Jul 2007)
New Revision: 3884

Modified:
   trunk/numpy/lib/shape_base.py
   trunk/numpy/lib/tests/test_shape_base.py
Log:
Tile empty arrays.


Modified: trunk/numpy/lib/shape_base.py
===================================================================
--- trunk/numpy/lib/shape_base.py	2007-07-06 19:42:46 UTC (rev 3883)
+++ trunk/numpy/lib/shape_base.py	2007-07-10 16:10:25 UTC (rev 3884)
@@ -620,7 +620,7 @@
     d = len(tup)
     c = _nx.array(A,copy=False,subok=True,ndmin=d)
     shape = list(c.shape)
-    n = c.size
+    n = max(c.size,1)
     if (d < c.ndim):
         tup = (1,)*(c.ndim-d) + tup
     for i, nrep in enumerate(tup):
@@ -629,5 +629,5 @@
         dim_in = shape[i]
         dim_out = dim_in*nrep
         shape[i] = dim_out
-        n /= dim_in
+        n /= max(dim_in,1)
     return c.reshape(shape)

Modified: trunk/numpy/lib/tests/test_shape_base.py
===================================================================
--- trunk/numpy/lib/tests/test_shape_base.py	2007-07-06 19:42:46 UTC (rev 3883)
+++ trunk/numpy/lib/tests/test_shape_base.py	2007-07-10 16:10:25 UTC (rev 3884)
@@ -384,6 +384,11 @@
         assert_equal(tile(b,(2,2)),[[1,2,1,2],[3,4,3,4],
                                     [1,2,1,2],[3,4,3,4]])
 
+    def check_empty(self):
+        a = array([[[]]])
+        d = tile(a,(3,2,5)).shape
+        assert_equal(d,(3,2,0))
+
     def check_kroncompare(self):
         import numpy.random as nr
         reps=[(2,),(1,2),(2,1),(2,2),(2,3,2),(3,2)]



More information about the Numpy-svn mailing list