Skip to content

Commit

Permalink
Merge pull request numpy#12123 from mattip/deprecate-asscalar
Browse files Browse the repository at this point in the history
DEP: deprecate asscalar
  • Loading branch information
charris authored Oct 10, 2018
2 parents c156bc1 + 263369c commit 3626bf4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
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 comments on commit 3626bf4

Please sign in to comment.