8000 DEP: deprecate asscalar by mattip · Pull Request #12123 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

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

Merged
merged 2 commits into from
Oct 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions doc/release/1.16.0-notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ and not documented. They will be removed in the 1.18 release. Use
These were deprecated in 1.10, had no tests, and seem to no longer work in
1.15 anyway.

`numpy.asscalar` has been deprecated
------------------------------------
It is an alias to the more powerful `numpy.ndarray.item`, not tested, and fails
for scalars.

Future Changes
==============
Expand Down
9 changes: 9 additions & 0 deletions numpy/lib/type_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

"""
from __future__ import division, absolute_import, print_function
import warnings

__all__ = ['iscomplexobj', 'isrealobj', 'imag', 'iscomplex',
'isreal', 'nan_to_num', 'real', 'real_if_close',
Expand Down Expand Up @@ -469,6 +470,10 @@ def asscalar(a):
"""
Convert an array of size 1 to its scalar equivalent.

.. deprecated:: 1.16

Deprecated, use `numpy.ndarray.item()` instead.

Parameters
----------
a : ndarray
Expand All @@ -486,6 +491,10 @@ def asscalar(a):
24

"""

# 2018-10-10, 1.16
warnings.warn('np.asscalar(a) is deprecated since NumPy v1.16, use '
'a.item() instead', DeprecationWarning, stacklevel=1)
return a.item()

#-----------------------------------------------------------------------------
Expand Down
0