diff options
author | Stefan van der Walt <stefan@sun.ac.za> | 2007-07-10 16:10:25 +0000 |
---|---|---|
committer | Stefan van der Walt <stefan@sun.ac.za> | 2007-07-10 16:10:25 +0000 |
commit | 18bc84c2799e7a476c4ed6620e7a36bc055fe6af (patch) | |
tree | 9ff16b2dafb51beaa4f7fb2af57bbd83cb1fd08b /numpy/lib | |
parent | e02d2e27677b932b90510b1b00d63d58b39e7ac4 (diff) | |
download | numpy-18bc84c2799e7a476c4ed6620e7a36bc055fe6af.tar.gz |
Tile empty arrays.
Diffstat (limited to 'numpy/lib')
-rw-r--r-- | numpy/lib/shape_base.py | 4 | ||||
-rw-r--r-- | numpy/lib/tests/test_shape_base.py | 5 |
2 files changed, 7 insertions, 2 deletions
diff --git a/numpy/lib/shape_base.py b/numpy/lib/shape_base.py index 2f9ecfa26..95b2bf2ce 100644 --- a/numpy/lib/shape_base.py +++ b/numpy/lib/shape_base.py @@ -620,7 +620,7 @@ def tile(A, reps): 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 @@ def tile(A, reps): 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) diff --git a/numpy/lib/tests/test_shape_base.py b/numpy/lib/tests/test_shape_base.py index 6efd2cdf1..b7b3458e4 100644 --- a/numpy/lib/tests/test_shape_base.py +++ b/numpy/lib/tests/test_shape_base.py @@ -384,6 +384,11 @@ class test_tile(NumpyTestCase): 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)] |