summaryrefslogtreecommitdiff
path: root/numpy/lib
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/lib')
-rw-r--r--numpy/lib/shape_base.py4
-rw-r--r--numpy/lib/tests/test_shape_base.py11
2 files changed, 13 insertions, 2 deletions
diff --git a/numpy/lib/shape_base.py b/numpy/lib/shape_base.py
index 16fd9d6b9..8f2a3014c 100644
--- a/numpy/lib/shape_base.py
+++ b/numpy/lib/shape_base.py
@@ -604,8 +604,8 @@ def tile(A, reps):
c = _nx.array(A,copy=False,subok=True,ndmin=d)
shape = list(c.shape)
n = c.size
- if (d < A.ndim):
- tup = (1,)*(A.ndim-d) + tup
+ if (d < c.ndim):
+ tup = (1,)*(c.ndim-d) + tup
for i, nrep in enumerate(tup):
if nrep!=1:
c = c.reshape(-1,n).repeat(nrep,0)
diff --git a/numpy/lib/tests/test_shape_base.py b/numpy/lib/tests/test_shape_base.py
index debd3ae8e..2704870b6 100644
--- a/numpy/lib/tests/test_shape_base.py
+++ b/numpy/lib/tests/test_shape_base.py
@@ -386,6 +386,17 @@ class test_kron(NumpyTestCase):
assert False, "ValueError expected"
+class test_tile(NumpyTestCase):
+ def check_basic(self):
+ a = array([0,1,2])
+ b = [[1,2],[3,4]]
+ assert_equal(tile(a,2), [0,1,2,0,1,2])
+ assert_equal(tile(a,(2,2)), [[0,1,2,0,1,2],[0,1,2,0,1,2]])
+ assert_equal(tile(a,(1,2)), [[0,1,2,0,1,2]])
+ assert_equal(tile(b, 2), [[1,2,1,2],[3,4,3,4]])
+ assert_equal(tile(b,(2,1)),[[1,2],[3,4],[1,2],[3,4]])
+ assert_equal(tile(b,(2,2)),[[1,2,1,2],[3,4,3,4],[1,2,1,2],[3,4,3,4]])
+
# Utility
def compare_results(res,desired):