Skip to content

DEP: Give a visible warning when align= to dtype is a non-bool #29301

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
Jul 2, 2025

Conversation

seberg
Copy link
Member

@seberg seberg commented Jul 1, 2025

This seems generally confusing. I would like to make it keyword only, but this already gives a warning when loading very old pickles, meaning I am not quite sure we should change away from a warning quickly.

We should fix things around pickling and start pickling in a way that makes it easier to move to keyword only arguments. (I suppose one could detect the case of np.dtype(obj, False, True) and assume it is via unpickling, but...

I am assuming that it is OK to (eventually) break unpickling these 10+ year old files, but I am not in a rush to actually do so and go through with the deprecation.

Closes gh-8158


The one way to really avoid all of those warnings for ancient pickles, might be to just explicitly accept np.dtype(obj, 0, 1) (and maybe the current np.dtype(obj, False, True)) exactly, basically just hoping that such a call came from pickle.

That is a whim, but users are unlikely to pass those exact parameters in practice probably...

This seems generally confusing. I would like to make it keyword only,
but this already gives a warning when loading _very_ old pickles, meaning
I am not quite sure we should change away from a warning quickly.

We should fix things around pickling and start pickling in a way that
makes it easier to move to keyword only arguments.  (I suppose one could
detect the case of `np.dtype(obj, False, True)` and assume it is via
unpickling, but...

I am assuming that it is OK to (eventually) break unpickling these 10+ year
old files, but I am not in a rush to actually do so and go through with
the deprecation.

Signed-off-by: Sebastian Berg <sebastianb@nvidia.com>
Copy link
Member

@mattip mattip left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, One tiny typo.

Co-authored-by: Matti Picus <matti.picus@gmail.com>
@mattip mattip merged commit b934a81 into numpy:main Jul 2, 2025
76 checks passed
@mattip
Copy link
Member

mattip commented Jul 2, 2025

Thanks @seberg

@seberg seberg deleted the dtype-align branch July 2, 2025 13:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

dtype ctor allows "align" kwargs even when unapplicable
2 participants