-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
DEP: deprecate asscalar #12123
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
DEP: deprecate asscalar #12123
Conversation
👍 This seems like a nice resolution to me. The function is basically useless. |
Hmm, what is the reason to only deprecate it in the docstring? Should it raise a deprecation warning? |
Agree that it needs a |
1c2a643
to
af5d32c
Compare
@charris thanks. Added actual deprecation warning. |
numpy/lib/type_check.py
Outdated
|
||
# 2018-10-10, 1.16 | ||
warnings.warn('asscalar will be removed in v1.18 of numpy', | ||
VisibleDeprecationWarning) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for VisibleDeprecationWarning
I think - use the normal one.
Also, this should suggest something like "use .item()
instead"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
numpy/lib/type_check.py
Outdated
@@ -467,7 +467,10 @@ def real_if_close(a,tol=100): | |||
|
|||
def asscalar(a): | |||
""" | |||
Convert an array of size 1 to its scalar equivalent. | |||
Convert an array of size 1 to its scalar equivalent. Deprecated, use | |||
`numpy.ndarray.item()` instead. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This second sentence should be indented under the .. deprecated
block
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved
af5d32c
to
1c2abd3
Compare
numpy/lib/type_check.py
Outdated
@@ -486,6 +491,10 @@ def asscalar(a): | |||
24 | |||
|
|||
""" | |||
|
|||
# 2018-10-10, 1.16 | |||
warnings.warn('np.asscalar(a) will be removed in v1.18 of numpy, use ' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we are headed toward using the version deprecated rather than the version in which we intend to remove it. The latter may change, the first is fixed and helps folks downstream know how to set up version dependent workarounds.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for fixing
Thanks Matti. |
Sorry, but why this handy function got deprecated in favor of |
@the-admax:
Both would fail if |
Closes #4701 (issue). Closes #11856 (PR). Closes #10256 (PR). Closes #10659 (PR).
This issue was labelled "easy" which led to the multiple PRs to fix it. I propose to deprecate it instead, as it is neither used nor tested in numpy, and is a thin wrapper to
ndarray.item()
but accepts none of theargs
.SciPy does not use
asscalar
, astropy has two uses ofasscalar
which would need fixing.