diff options
author | Matti Picus <matti.picus@gmail.com> | 2020-03-06 00:23:43 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-06 00:23:43 +0200 |
commit | ff4cfe7ecd46ee15fd88297964f6a5cb5423c291 (patch) | |
tree | ab318ae312db68d4329e23ade0457a9f026dbb4c /numpy/core/tests | |
parent | 901211eddd5e17c8c7c85bc5f791679559d4efb5 (diff) | |
parent | a5a653d25e7329b9366be6f44b052d41bf297b0f (diff) | |
download | numpy-ff4cfe7ecd46ee15fd88297964f6a5cb5423c291.tar.gz |
Merge pull request #15534 from seberg/deprecate-abstract-scalar-types
DEP: Do not allow "abstract" dtype conversion/creation
Diffstat (limited to 'numpy/core/tests')
-rw-r--r-- | numpy/core/tests/test_defchararray.py | 4 | ||||
-rw-r--r-- | numpy/core/tests/test_deprecations.py | 30 |
2 files changed, 32 insertions, 2 deletions
diff --git a/numpy/core/tests/test_defchararray.py b/numpy/core/tests/test_defchararray.py index 39600553d..bbb94f7d3 100644 --- a/numpy/core/tests/test_defchararray.py +++ b/numpy/core/tests/test_defchararray.py @@ -119,14 +119,14 @@ class TestVecString: def test_invalid_result_type(self): def fail(): - _vec_string(['a'], np.integer, 'strip') + _vec_string(['a'], np.int_, 'strip') assert_raises(TypeError, fail) def test_broadcast_error(self): def fail(): - _vec_string([['abc', 'def']], np.integer, 'find', (['a', 'd', 'j'],)) + _vec_string([['abc', 'def']], np.int_, 'find', (['a', 'd', 'j'],)) assert_raises(ValueError, fail) diff --git a/numpy/core/tests/test_deprecations.py b/numpy/core/tests/test_deprecations.py index 01b35ec90..d2cf315a9 100644 --- a/numpy/core/tests/test_deprecations.py +++ b/numpy/core/tests/test_deprecations.py @@ -547,3 +547,33 @@ def test_deprecate_ragged_arrays(): with assert_warns(np.VisibleDeprecationWarning): np.array(arg) + +class TestDTypeCoercion(_DeprecationTestCase): + # 2020-02-06 1.19.0 + message = "Converting .* to a dtype .*is deprecated" + deprecated_types = [ + # The builtin scalar super types: + np.generic, np.flexible, np.number, + np.inexact, np.floating, np.complexfloating, + np.integer, np.unsignedinteger, np.signedinteger, + # character is a deprecated S1 special case: + np.character, + ] + + def test_dtype_coercion(self): + for scalar_type in self.deprecated_types: + self.assert_deprecated(np.dtype, args=(scalar_type,)) + + def test_array_construction(self): + for scalar_type in self.deprecated_types: + self.assert_deprecated(np.array, args=([], scalar_type,)) + + def test_not_deprecated(self): + # All specific types are not deprecated: + 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,)) |