From 71a924ee7f71f1ea14af3aee0a6be29353a996d4 Mon Sep 17 00:00:00 2001 From: Sebastian Berg Date: Fri, 25 Nov 2022 16:38:28 +0100 Subject: BUG: Ensure string aliases `"int0"`, etc. remain valid for now int0 and uint0 were accidentally dropped, the others just added as a test. We did successfully remove many Numeric types before, so these could probably be deprecated (it is a bit more annoying to do). These could probably just be removed, scikit-learn only noticed it in a single test (scipy probably not at all). But maybe not in 1.24 --- numpy/core/_type_aliases.py | 3 ++- numpy/core/tests/test_dtype.py | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) (limited to 'numpy/core') diff --git a/numpy/core/_type_aliases.py b/numpy/core/_type_aliases.py index 5adabfb03..38f1a099e 100644 --- a/numpy/core/_type_aliases.py +++ b/numpy/core/_type_aliases.py @@ -233,7 +233,8 @@ _set_array_types() # Add additional strings to the sctypeDict _toadd = ['int', 'float', 'complex', 'bool', 'object', - 'str', 'bytes', ('a', 'bytes_')] + 'str', 'bytes', ('a', 'bytes_'), + ('int0', 'intp'), ('uint0', 'uintp')] for name in _toadd: if isinstance(name, tuple): diff --git a/numpy/core/tests/test_dtype.py b/numpy/core/tests/test_dtype.py index 91f314d05..b4dce677e 100644 --- a/numpy/core/tests/test_dtype.py +++ b/numpy/core/tests/test_dtype.py @@ -126,6 +126,15 @@ class TestBuiltin: with assert_raises(TypeError): np.dtype(dtype) + def test_remaining_dtypes_with_bad_bytesize(self): + # These should probably deprecated as well, the np. aliases were + assert np.dtype("int0") is np.dtype("intp") + assert np.dtype("uint0") is np.dtype("uintp") + assert np.dtype("bool8") is np.dtype("bool") + assert np.dtype("bytes0") is np.dtype("bytes") + assert np.dtype("str0") is np.dtype("str") + assert np.dtype("object0") is np.dtype("object") + @pytest.mark.parametrize( 'value', ['m8', 'M8', 'datetime64', 'timedelta64', -- cgit v1.2.1 From 6b606389b2747a455ba8c23bdc3ed6b1ed8c000b Mon Sep 17 00:00:00 2001 From: Sebastian Berg Date: Sun, 27 Nov 2022 18:42:05 +0100 Subject: Update numpy/core/tests/test_dtype.py Co-authored-by: Matti Picus --- numpy/core/tests/test_dtype.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'numpy/core') diff --git a/numpy/core/tests/test_dtype.py b/numpy/core/tests/test_dtype.py index b4dce677e..0a56483d6 100644 --- a/numpy/core/tests/test_dtype.py +++ b/numpy/core/tests/test_dtype.py @@ -127,7 +127,7 @@ class TestBuiltin: np.dtype(dtype) def test_remaining_dtypes_with_bad_bytesize(self): - # These should probably deprecated as well, the np. aliases were + # The np. aliases were deprecated, these probably should be too assert np.dtype("int0") is np.dtype("intp") assert np.dtype("uint0") is np.dtype("uintp") assert np.dtype("bool8") is np.dtype("bool") -- cgit v1.2.1