Content-Length: 246652 | pFad | http://github.com/numpy/numpy/issues/28670

72 BUG: StringDType `.str` property is confusing · Issue #28670 · numpy/numpy · GitHub
Skip to content

BUG: StringDType .str property is confusing #28670

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
crusaderky opened this issue Apr 8, 2025 · 2 comments · Fixed by #28923
Closed

BUG: StringDType .str property is confusing #28670

crusaderky opened this issue Apr 8, 2025 · 2 comments · Fixed by #28923
Labels

Comments

@crusaderky
Copy link
Contributor

crusaderky commented Apr 8, 2025

Describe the issue:

The output of str(np.dtypes.StringDType()) is 'StringDType()'.
The output of np.dtypes.StringDType().str is '|T16'.

I think that the .str output is quite uninformative, and it would be much better as 'StringDType()' too.
Namely, I don't think that the final user should be exposed to the word-size, which is not representative of the consumed memory, is an implementation detail, and (to my understanding) changes between 32 and 64 bit architectures.

Reproduce the code example:

>>> np.dtypes.StringDType().str
|T16

Python and NumPy Versions:

NumPy 2.2.4

Context for the issue:

h5py/h5py#2557 (comment)

versioned_hdf5, like many other wrappers around NumPy dtypes, needs to pretty-print metadata information in their __repr__ methods. We had to special-case around this.

@ngoldbaum
Copy link
Member

Another reason to make this change (besides |T16 being basically useless) is it drops the parameters for the dtype, which might be very confusing if someone e.g. sets an na_object.

@ngoldbaum
Copy link
Member

And it probably also makes sense to make str use the string conversion defined on the dtype object for all new-style DTypes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/numpy/numpy/issues/28670

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy