DEP: Deprecate NumPy object scalars#16850
Merged
mattip merged 1 commit intonumpy:masterfrom Jul 21, 2020
Merged
Conversation
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__`.
anirudh2290
reviewed
Jul 21, 2020
Member
anirudh2290
left a comment
There was a problem hiding this comment.
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 " |
Member
There was a problem hiding this comment.
Should we link to the issue tracker here ?
Member
There was a problem hiding this comment.
I think it is fine like this, people who might be doing this should know where to find us.
Member
|
Thanks @seberg |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.