summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2015-06-20 16:59:46 -0600
committerCharles Harris <charlesr.harris@gmail.com>2015-06-21 14:17:57 -0600
commitbac2fdf7c02b4bc07b9c05dbb6551004903279ca (patch)
tree8e2784d686fbb837ed9b80f12335d639103cfee0 /numpy
parentec4e91b08f52b19b9c87f6020cac99027023038b (diff)
downloadnumpy-bac2fdf7c02b4bc07b9c05dbb6551004903279ca.tar.gz
DEP,MAINT: Remove old_behavior keyword from numeric.correlate.
Risky perhaps. The old correlate behavior was deprecated in NumPy 1.4 and the default behavior changed to the new (standard) version in 1.5. The old function, with slightly different signature, is still available in numpy.core.multiarray.correlate. If this causes problems in the 1.10 release process, this commit can be reverted.
Diffstat (limited to 'numpy')
-rw-r--r--numpy/core/numeric.py24
-rw-r--r--numpy/core/tests/test_numeric.py53
2 files changed, 17 insertions, 60 deletions
diff --git a/numpy/core/numeric.py b/numpy/core/numeric.py
index 24d92f16f..35a6deaff 100644
--- a/numpy/core/numeric.py
+++ b/numpy/core/numeric.py
@@ -831,7 +831,7 @@ def _mode_from_name(mode):
return _mode_from_name_dict[mode.lower()[0]]
return mode
-def correlate(a, v, mode='valid', old_behavior=False):
+def correlate(a, v, mode='valid'):
"""
Cross-correlation of two 1-dimensional sequences.
@@ -851,10 +851,8 @@ def correlate(a, v, mode='valid', old_behavior=False):
Refer to the `convolve` docstring. Note that the default
is `valid`, unlike `convolve`, which uses `full`.
old_behavior : bool
- If True, uses the old behavior from Numeric,
- (correlate(a,v) == correlate(v,a), and the conjugate is not taken
- for complex arrays). If False, uses the conventional signal
- processing definition.
+ `old_behavior` was removed in NumPy 1.10. If you need the old
+ behavior, use `multiarray.correlate`.
Returns
-------
@@ -864,6 +862,7 @@ def correlate(a, v, mode='valid', old_behavior=False):
See Also
--------
convolve : Discrete, linear convolution of two one-dimensional sequences.
+ multiarray.correlate : Old, no conjugate, version of correlate.
Notes
-----
@@ -897,20 +896,7 @@ def correlate(a, v, mode='valid', old_behavior=False):
"""
mode = _mode_from_name(mode)
-# the old behavior should be made available under a different name, see thread
-# http://thread.gmane.org/gmane.comp.python.numeric.general/12609/focus=12630
- if old_behavior:
- # 2009-07-18 Cannot remove without replacement function.
- warnings.warn("""
-The old behavior of correlate was deprecated for 1.4.0, and will be completely removed
-for NumPy 2.0.
-
-The new behavior fits the conventional definition of correlation: inputs are
-never swapped, and the second argument is conjugated for complex arrays.""",
- DeprecationWarning)
- return multiarray.correlate(a, v, mode)
- else:
- return multiarray.correlate2(a, v, mode)
+ return multiarray.correlate2(a, v, mode)
def convolve(a,v,mode='full'):
"""
diff --git a/numpy/core/tests/test_numeric.py b/numpy/core/tests/test_numeric.py
index 7400366ac..c39900ffa 100644
--- a/numpy/core/tests/test_numeric.py
+++ b/numpy/core/tests/test_numeric.py
@@ -980,6 +980,7 @@ class TestBinaryRepr(TestCase):
assert_equal(binary_repr(-1), '-1')
assert_equal(binary_repr(-1, width=8), '11111111')
+
class TestBaseRepr(TestCase):
def test_base3(self):
assert_equal(base_repr(3**5, 3), '100000')
@@ -1946,7 +1947,7 @@ class TestLikeFuncs(TestCase):
self.check_like_function(np.full_like, 123.456, True)
self.check_like_function(np.full_like, np.inf, True)
-class _TestCorrelate(TestCase):
+class TestCorrelate(TestCase):
def _setup(self, dt):
self.x = np.array([1, 2, 3, 4, 5], dtype=dt)
self.xs = np.arange(1, 20)[::3]
@@ -1961,24 +1962,24 @@ class _TestCorrelate(TestCase):
def test_float(self):
self._setup(np.float)
- z = np.correlate(self.x, self.y, 'full', old_behavior=self.old_behavior)
+ z = np.correlate(self.x, self.y, 'full')
assert_array_almost_equal(z, self.z1)
- z = np.correlate(self.x, self.y[:-1], 'full', old_behavior=self.old_behavior)
+ z = np.correlate(self.x, self.y[:-1], 'full')
assert_array_almost_equal(z, self.z1_4)
- z = np.correlate(self.y, self.x, 'full', old_behavior=self.old_behavior)
+ z = np.correlate(self.y, self.x, 'full')
assert_array_almost_equal(z, self.z2)
- z = np.correlate(self.x[::-1], self.y, 'full', old_behavior=self.old_behavior)
+ z = np.correlate(self.x[::-1], self.y, 'full')
assert_array_almost_equal(z, self.z1r)
- z = np.correlate(self.y, self.x[::-1], 'full', old_behavior=self.old_behavior)
+ z = np.correlate(self.y, self.x[::-1], 'full')
assert_array_almost_equal(z, self.z2r)
- z = np.correlate(self.xs, self.y, 'full', old_behavior=self.old_behavior)
+ z = np.correlate(self.xs, self.y, 'full')
assert_array_almost_equal(z, self.zs)
def test_object(self):
self._setup(Decimal)
- z = np.correlate(self.x, self.y, 'full', old_behavior=self.old_behavior)
+ z = np.correlate(self.x, self.y, 'full')
assert_array_almost_equal(z, self.z1)
- z = np.correlate(self.y, self.x, 'full', old_behavior=self.old_behavior)
+ z = np.correlate(self.y, self.x, 'full')
assert_array_almost_equal(z, self.z2)
def test_no_overwrite(self):
@@ -1988,45 +1989,15 @@ class _TestCorrelate(TestCase):
assert_array_equal(d, np.ones(100))
assert_array_equal(k, np.ones(3))
-class TestCorrelate(_TestCorrelate):
- old_behavior = True
- def _setup(self, dt):
- # correlate uses an unconventional definition so that correlate(a, b)
- # == correlate(b, a), so force the corresponding outputs to be the same
- # as well
- _TestCorrelate._setup(self, dt)
- self.z2 = self.z1
- self.z2r = self.z1r
-
- @dec.deprecated()
- def test_complex(self):
- x = np.array([1, 2, 3, 4+1j], dtype=np.complex)
- y = np.array([-1, -2j, 3+1j], dtype=np.complex)
- r_z = np.array([3+1j, 6, 8-1j, 9+1j, -1-8j, -4-1j], dtype=np.complex)
- z = np.correlate(x, y, 'full', old_behavior=self.old_behavior)
- assert_array_almost_equal(z, r_z)
-
- @dec.deprecated()
- def test_float(self):
- _TestCorrelate.test_float(self)
-
- @dec.deprecated()
- def test_object(self):
- _TestCorrelate.test_object(self)
-
-class TestCorrelateNew(_TestCorrelate):
- old_behavior = False
def test_complex(self):
x = np.array([1, 2, 3, 4+1j], dtype=np.complex)
y = np.array([-1, -2j, 3+1j], dtype=np.complex)
r_z = np.array([3-1j, 6, 8+1j, 11+5j, -5+8j, -4-1j], dtype=np.complex)
- #z = np.acorrelate(x, y, 'full')
- #assert_array_almost_equal(z, r_z)
-
r_z = r_z[::-1].conjugate()
- z = np.correlate(y, x, 'full', old_behavior=self.old_behavior)
+ z = correlate(y, x, mode='full')
assert_array_almost_equal(z, r_z)
+
class TestConvolve(TestCase):
def test_object(self):
d = [1.] * 100