Skip to content

BUG: Deprecate unsupported dtype aliases #24892

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

Closed
mroeschke opened this issue Oct 9, 2023 · 6 comments
Closed

BUG: Deprecate unsupported dtype aliases #24892

mroeschke opened this issue Oct 9, 2023 · 6 comments

Comments

@mroeschke
Copy link
Contributor

mroeschke commented Oct 9, 2023

Describe the issue:

#24679 appears to have accidentially removed dtype aliases that used to work

Reproduce the code example:

In [1]: import numpy as np

In [2]: np.__version__
Out[2]: '1.24.4'

In [3]: np.dtype("unicode")
Out[3]: dtype('<U')

In [4]: np.dtype("a1")
Out[4]: dtype('S1')


>>> import numpy as np
>>> np.dtype("unicode")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: data type 'unicode' not understood
>>> np.dtype("a1")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: data type 'a1' not understood
>>> np.__version__
'2.0.0.dev0+git20231007.040ed2d'

Error message:

No response

Runtime information:

>>> np.__version__
'2.0.0.dev0+git20231007.040ed2d'

Context for the issue:

No response

@mtsokol
Copy link
Member

mtsokol commented Oct 9, 2023

@mroeschke np.dtype("a") was removed on purpose here: #24854. np.dtype("S") should be used instead.

@mroeschke
Copy link
Contributor Author

np.dtype("a") was removed on purpose here: #24854.

Sounds good. I can update np.dtype("a") usage in pandas

@ngoldbaum
Copy link
Member

We could probably make the error message for trying to create an aN dtype nicer though.

Also if we get more details about the need for supporting "a" we could bring it back as a deprecated alias instead. I don't think we want to keep it forever because it's confusing: it's short for ascii and represents the bytes dtype, which is not necessarily ascii.

@mroeschke
Copy link
Contributor Author

On the pandas side, there's no need to keep supporting "a"

@mhvk
Copy link
Contributor

mhvk commented Oct 9, 2023

I just introduced an astropy PR to remove our usage of "a" dtype - astropy/astropy#15454

While it would have been nice if there had been deprecation warnings earlier, I also agree there is not much need to deprecate it now - we have been expecting breakage with numpy 2.0 (I do worry how close to our November feature freeze all this is happening...).

@ngoldbaum
Copy link
Member

When I searched on github, I only found a couple dozen obscure usages and missed that both pandas and astropy are using it. That argues for merely deprecating it I think.

@ngoldbaum ngoldbaum added this to the 2.0.0 release milestone Oct 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants