Skip to content

ENH: expose numpy.dtype.flags bitmasks in numpy.dtypes #24963

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

Open
graingert opened this issue Oct 19, 2023 · 4 comments
Open

ENH: expose numpy.dtype.flags bitmasks in numpy.dtypes #24963

graingert opened this issue Oct 19, 2023 · 4 comments

Comments

@graingert
Copy link
Contributor

graingert commented Oct 19, 2023

Proposed new feature or change:

currently the numpy.dtype.flags bitmasks are exposed in numpy._core.multiarray

the flag numpy._core.multiarray.LIST_PICKLE is used by distributed to determine how best to pickle an ndarray so it would be great if there were a public namespace to access these flags, eg numpy.dtypes.LIST_PICKLE

@seberg seberg added this to the 2.0.0 release milestone Oct 19, 2023
@seberg
Copy link
Member

seberg commented Oct 19, 2023

We had discussed that a bit on slack. A neat way would also be to make the flags return an enum.IntFlags. The class of which might fit into np.dtypes (better repr and reduces the spam in the module)

@ngoldbaum
Copy link
Member

Another way to solve this without exposing the flags in python would be to add a member hanging off the dtype object that indicates if it's supposed to be pickled for serialization (that internally would do the check against the flags).

@ngoldbaum
Copy link
Member

It is pretty niche, but the property hanging off the dtype object is also pretty easy to implement - just add a new function that does the flag check and add an entry for it in the arraydescr_getsets array in numpy/_core/src/multiarray/descriptor.c.

Exposing all the flags to python would also work, and I guess we already expose the flags too so exposing the whole enum probably makes sense, just wanted to comment that the property is also not very hard to add.

@seberg
Copy link
Member

seberg commented Oct 19, 2023

Yes, a proprety is fine, I would like to not spoil the properties too much with things users will never really need, but overall it is not a big issue.

@seberg seberg modified the milestones: 2.0.0 release, 2.1.0 release Jan 31, 2024
@charris charris modified the milestones: 2.1.0 release, 2.2.0 release Aug 1, 2024
@charris charris modified the milestones: 2.2.0 release, 2.3.0 release Nov 22, 2024
@charris charris modified the milestones: 2.3.0 release, 2.4.0 release May 20, 2025
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
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy