diff options
author | Sebastian Berg <sebastian@sipsolutions.net> | 2020-02-07 11:33:45 -0800 |
---|---|---|
committer | Sebastian Berg <sebastian@sipsolutions.net> | 2020-02-07 13:47:19 -0800 |
commit | cefd3523a63cfd5ede693d53d3821e37fa8ca158 (patch) | |
tree | 627bd350cef3c2dbf81b6efa51b58c5d108475ed /numpy/core/tests | |
parent | 1a1611a33cfb5ea50d16d20affa5c6fa03e148d7 (diff) | |
download | numpy-cefd3523a63cfd5ede693d53d3821e37fa8ca158.tar.gz |
Fixup: Do not deprecate generic python types
Add a comment that we can think about only allowing it for `dtype=...`
though...
Diffstat (limited to 'numpy/core/tests')
-rw-r--r-- | numpy/core/tests/test_deprecations.py | 9 | ||||
-rw-r--r-- | numpy/core/tests/test_multiarray.py | 2 | ||||
-rw-r--r-- | numpy/core/tests/test_numeric.py | 2 | ||||
-rw-r--r-- | numpy/core/tests/test_numerictypes.py | 10 | ||||
-rw-r--r-- | numpy/core/tests/test_regression.py | 2 |
5 files changed, 11 insertions, 14 deletions
diff --git a/numpy/core/tests/test_deprecations.py b/numpy/core/tests/test_deprecations.py index a89fc70d5..d2cf315a9 100644 --- a/numpy/core/tests/test_deprecations.py +++ b/numpy/core/tests/test_deprecations.py @@ -548,7 +548,7 @@ def test_deprecate_ragged_arrays(): np.array(arg) -class TestAbstractDTypeCoercion(_DeprecationTestCase): +class TestDTypeCoercion(_DeprecationTestCase): # 2020-02-06 1.19.0 message = "Converting .* to a dtype .*is deprecated" deprecated_types = [ @@ -558,9 +558,6 @@ class TestAbstractDTypeCoercion(_DeprecationTestCase): np.integer, np.unsignedinteger, np.signedinteger, # character is a deprecated S1 special case: np.character, - # Test python types that do not map to a NumPy type cleanly - # (currenlty map to object) - type, list, tuple, dict, ] def test_dtype_coercion(self): @@ -576,3 +573,7 @@ class TestAbstractDTypeCoercion(_DeprecationTestCase): for group in np.sctypes.values(): for scalar_type in group: self.assert_not_deprecated(np.dtype, args=(scalar_type,)) + + for scalar_type in [type, dict, list, tuple]: + # Typical python types are coerced to object currently: + self.assert_not_deprecated(np.dtype, args=(scalar_type,)) diff --git a/numpy/core/tests/test_multiarray.py b/numpy/core/tests/test_multiarray.py index f6181c900..ad38911cb 100644 --- a/numpy/core/tests/test_multiarray.py +++ b/numpy/core/tests/test_multiarray.py @@ -6456,7 +6456,7 @@ class TestRepeat: NEIGH_MODE = {'zero': 0, 'one': 1, 'constant': 2, 'circular': 3, 'mirror': 4} -@pytest.mark.parametrize('dt', [float, object], ids=['float', 'object']) +@pytest.mark.parametrize('dt', [float, Decimal], ids=['float', 'object']) class TestNeighborhoodIter: # Simple, 2d tests def test_simple2d(self, dt): diff --git a/numpy/core/tests/test_numeric.py b/numpy/core/tests/test_numeric.py index 0f7ac036f..3bc4cd187 100644 --- a/numpy/core/tests/test_numeric.py +++ b/numpy/core/tests/test_numeric.py @@ -2543,7 +2543,7 @@ class TestCorrelate: assert_array_almost_equal(z, self.zs) def test_object(self): - self._setup(object) + self._setup(Decimal) z = np.correlate(self.x, self.y, 'full') assert_array_almost_equal(z, self.z1) z = np.correlate(self.y, self.x, 'full') diff --git a/numpy/core/tests/test_numerictypes.py b/numpy/core/tests/test_numerictypes.py index 22fc2ed58..c72d13947 100644 --- a/numpy/core/tests/test_numerictypes.py +++ b/numpy/core/tests/test_numerictypes.py @@ -3,8 +3,7 @@ import itertools import pytest import numpy as np -from numpy.testing import ( - assert_, assert_equal, assert_raises, assert_warns, IS_PYPY) +from numpy.testing import assert_, assert_equal, assert_raises, IS_PYPY # This is the structure of the table used for plain objects: # @@ -452,11 +451,8 @@ class Test_sctype2char: def test_other_type(self): assert_equal(np.sctype2char(float), 'd') - assert_equal(np.sctype2char(object), 'O') - with assert_warns(DeprecationWarning): - assert_equal(np.sctype2char(list), 'O') - with assert_warns(DeprecationWarning): - assert_equal(np.sctype2char(np.ndarray), 'O') + assert_equal(np.sctype2char(list), 'O') + assert_equal(np.sctype2char(np.ndarray), 'O') def test_third_party_scalar_type(self): from numpy.core._rational_tests import rational diff --git a/numpy/core/tests/test_regression.py b/numpy/core/tests/test_regression.py index 50a543625..321723b9b 100644 --- a/numpy/core/tests/test_regression.py +++ b/numpy/core/tests/test_regression.py @@ -1152,7 +1152,7 @@ class TestRegression: assert_(dat.argmax(1).info == 'jubba') assert_(dat.argmin(1).info == 'jubba') assert_(dat.argsort(1).info == 'jubba') - assert_(dat.astype(object).info == 'jubba') + assert_(dat.astype(TestArray).info == 'jubba') assert_(dat.byteswap().info == 'jubba') assert_(dat.clip(2, 7).info == 'jubba') assert_(dat.compress([0, 1, 1]).info == 'jubba') |