Thanks to visit codestin.com
Credit goes to github.com

Skip to content

BUG: Ensure string aliases "int0", etc. remain valid for now #22699

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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