diff options
| author | Matti Picus <matti.picus@gmail.com> | 2022-11-27 21:55:46 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-11-27 21:55:46 +0200 |
| commit | f07bb7ac7fdc5d1ff076f9cacc0f7927b3fea184 (patch) | |
| tree | 24ce91e39219d2e8e6160e1247b7a0b27e65444d | |
| parent | 57f704ae8dba5d013b63c93367c115f7cd0b0518 (diff) | |
| parent | 6b606389b2747a455ba8c23bdc3ed6b1ed8c000b (diff) | |
| download | numpy-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.py | 3 | ||||
| -rw-r--r-- | numpy/core/tests/test_dtype.py | 9 |
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', |
