From a5ea773e66110cf335c9ed37e8ccdc14f8e56764 Mon Sep 17 00:00:00 2001 From: Oliver Eberle Date: Thu, 19 Feb 2015 15:24:47 +0100 Subject: 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. --- numpy/lib/shape_base.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'numpy/lib/shape_base.py') 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): -- cgit v1.2.1 From 6eef837b4ae321e8bd2dffab4df68a4869f00860 Mon Sep 17 00:00:00 2001 From: Kreiswolke Date: Wed, 11 Mar 2015 13:07:22 +0100 Subject: Update shape_base.py So removed the paranthesis and included the return statement. --- numpy/lib/shape_base.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'numpy/lib/shape_base.py') diff --git a/numpy/lib/shape_base.py b/numpy/lib/shape_base.py index 4acdf4a77..011434dda 100644 --- a/numpy/lib/shape_base.py +++ b/numpy/lib/shape_base.py @@ -850,10 +850,10 @@ def tile(A, reps): except TypeError: tup = (reps,) d = len(tup) - if all((x == 1 for x in tup)) and isinstance(A, _nx.ndarray): + 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) + return _nx.array(A, copy=True, subok=True, ndmin=d) else: c = _nx.array(A, copy=False, subok=True, ndmin=d) shape = list(c.shape) -- cgit v1.2.1