summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatti Picus <matti.picus@gmail.com>2022-11-27 21:55:46 +0200
committerGitHub <noreply@github.com>2022-11-27 21:55:46 +0200
commitf07bb7ac7fdc5d1ff076f9cacc0f7927b3fea184 (patch)
tree24ce91e39219d2e8e6160e1247b7a0b27e65444d
parent57f704ae8dba5d013b63c93367c115f7cd0b0518 (diff)
parent6b606389b2747a455ba8c23bdc3ed6b1ed8c000b (diff)
downloadnumpy-f07bb7ac7fdc5d1ff076f9cacc0f7927b3fea184.tar.gz
Merge pull request #22676 from seberg/issue-22672
BUG: Ensure string aliases `"int0"`, etc. remain valid for now
-rw-r--r--numpy/core/_type_aliases.py3
-rw-r--r--numpy/core/tests/test_dtype.py9
2 files changed, 11 insertions, 1 deletions
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..0a56483d6 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):
+ # The np.<name> 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")
+ 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',