summaryrefslogtreecommitdiff
path: root/numpy/lib/shape_base.py
diff options
context:
space:
mode:
authorOliver Eberle <oliver_eberle@web.de>2015-02-19 15:24:47 +0100
committerOliver Eberle <oliver_eberle@web.de>2015-02-19 15:35:09 +0100
commita5ea773e66110cf335c9ed37e8ccdc14f8e56764 (patch)
treeac3d7f2dcdb0876fbdb57417bd0d11a77432bc21 /numpy/lib/shape_base.py
parentd770034969e35907e7497d5fe9053df4bdac2fd2 (diff)
downloadnumpy-a5ea773e66110cf335c9ed37e8ccdc14f8e56764.tar.gz
BUG: Fixed issue #4679 and added test
Tile now copies the input when it is a numpy array and all dimensions are repeated only once.
Diffstat (limited to 'numpy/lib/shape_base.py')
-rw-r--r--numpy/lib/shape_base.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/numpy/lib/shape_base.py b/numpy/lib/shape_base.py
index 2d18c5bc8..4acdf4a77 100644
--- a/numpy/lib/shape_base.py
+++ b/numpy/lib/shape_base.py
@@ -850,7 +850,12 @@ def tile(A, reps):
except TypeError:
tup = (reps,)
d = len(tup)
- c = _nx.array(A, copy=False, subok=True, ndmin=d)
+ if all((x == 1 for x in tup)) and isinstance(A, _nx.ndarray):
+ # Fixes the problem that the function does not make a copy if A is a
+ # numpy array and the repetitions are 1 in all dimensions
+ c = _nx.array(A, copy=True, subok=True, ndmin=d)
+ else:
+ c = _nx.array(A, copy=False, subok=True, ndmin=d)
shape = list(c.shape)
n = max(c.size, 1)
if (d < c.ndim):