diff options
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/core/numeric.py | 2 | ||||
-rw-r--r-- | numpy/core/tests/test_numeric.py | 20 |
2 files changed, 21 insertions, 1 deletions
diff --git a/numpy/core/numeric.py b/numpy/core/numeric.py index 5d7407ce0..efd8af45d 100644 --- a/numpy/core/numeric.py +++ b/numpy/core/numeric.py @@ -985,7 +985,7 @@ def convolve(a,v,mode='full'): array([ 2.5]) """ - a, v = array(a, ndmin=1), array(v, ndmin=1) + a, v = array(a, copy=False, ndmin=1), array(v, copy=False, ndmin=1) if (len(v) > len(a)): a, v = v, a if len(a) == 0 : diff --git a/numpy/core/tests/test_numeric.py b/numpy/core/tests/test_numeric.py index 483484467..3dea80d14 100644 --- a/numpy/core/tests/test_numeric.py +++ b/numpy/core/tests/test_numeric.py @@ -1920,6 +1920,13 @@ class _TestCorrelate(TestCase): z = np.correlate(self.y, self.x, 'full', old_behavior=self.old_behavior) assert_array_almost_equal(z, self.z2) + def test_no_overwrite(self): + d = np.ones(100) + k = np.ones(3) + np.correlate(d, k) + assert_array_equal(d, np.ones(100)) + assert_array_equal(k, np.ones(3)) + class TestCorrelate(_TestCorrelate): old_behavior = True def _setup(self, dt): @@ -1958,6 +1965,19 @@ class TestCorrelateNew(_TestCorrelate): z = np.correlate(y, x, 'full', old_behavior=self.old_behavior) assert_array_almost_equal(z, r_z) +class TestConvolve(TestCase): + def test_object(self): + d = [1.] * 100 + k = [1.] * 3 + assert_array_almost_equal(np.convolve(d, k)[2:-2], np.full(98, 3)) + + def test_no_overwrite(self): + d = np.ones(100) + k = np.ones(3) + np.convolve(d, k) + assert_array_equal(d, np.ones(100)) + assert_array_equal(k, np.ones(3)) + class TestArgwhere(object): def test_2D(self): x = np.arange(6).reshape((2, 3)) |