8000 DEP: Deprecate NumPy object scalars by seberg · Pull Request #16850 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

DEP: Deprecate NumPy object scalars #16850

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 1 commit into from
Jul 21, 2020

Conversation

seberg
Copy link
Member
@seberg seberg commented Jul 13, 2020

NumPy object scalars should not exist, since they should always
just return the actual scalar in the first place. Put a deprecation
warning in place to be rapidly changed into a TypeError.

Once allocating it gives an error, we can make all methods raise
errors (with the exception of __new__.


It is not possible to test this branch, to test it you have to manuall undo gh-16817 and run a = np.ones(1, dtype=('O', [('name', 'O')]))[0] which used to be a bug that actually created object scalars.

NumPy object scalars should not exist, since they should always
just return the actual scalar in the first place. Put a deprecation
warning in place to be rapidly changed into a TypeError.

Once allocating it gives an error, we can make all methods raise
errors (with the exception of `__new__`.
Copy link
Member
@anirudh2290 anirudh2290 left a comment

Choose a reason for hiding this comment

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

This LGTM. Doesn't look like we hit this alloc right now.

if (PyErr_WarnEx(visibleDeprecationWarning,
"Creating a NumPy object scalar. NumPy object scalars should "
"never be created. If you see this message please inform the "
"NumPy developers. Since this message should never be shown "
Copy link
Member

Choose a reason for hiding this comment

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

Should we link to the issue tracker here ?

Copy link
Member

Choose a reason for hiding this comment

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

I think it is fine like this, people who might be doing this should know where to find us.

@mattip mattip merged commit 5a429f7 into numpy:master Jul 21, 2020
@mattip
Copy link
Member
mattip commented Jul 21, 2020

Thanks @seberg

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.

4 participants
0