Skip to content

Commit

Permalink
Merge pull request #22676 from seberg/issue-22672
Browse files Browse the repository at this point in the history
BUG: Ensure string aliases `"int0"`, etc. remain valid for now
  • Loading branch information
mattip committed Nov 27, 2022
2 parents 57f704a + 6b60638 commit f07bb7a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion numpy/core/_type_aliases.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,8 @@ def _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):
Expand Down
9 changes: 9 additions & 0 deletions numpy/core/tests/test_dtype.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,15 @@ def test_numeric_style_types_are_invalid(self, dtype):
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',
Expand Down

0 comments on commit f07bb7a

Please sign in to comment.