Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1c2abd3

Browse files
committed
DEP: deprecate asscalar
1 parent 86a7acc commit 1c2abd3

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

doc/release/1.16.0-notes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ and not documented. They will be removed in the 1.18 release. Use
3636
These were deprecated in 1.10, had no tests, and seem to no longer work in
3737
1.15 anyway.
3838

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

4044
Future Changes
4145
==============

numpy/lib/type_check.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
33
"""
44
from __future__ import division, absolute_import, print_function
5+
import warnings
56

67
__all__ = ['iscomplexobj', 'isrealobj', 'imag', 'iscomplex',
78
'isreal', 'nan_to_num', 'real', 'real_if_close',
@@ -469,6 +470,10 @@ def asscalar(a):
469470
"""
470471
Convert an array of size 1 to its scalar equivalent.
471472
473+
.. deprecated:: 1.16
474+
475+
Deprecated, use `numpy.ndarray.item()` instead.
476+
472477
Parameters
473478
----------
474479
a : ndarray
@@ -486,6 +491,10 @@ def asscalar(a):
486491
24
487492
488493
"""
494+
495+
# 2018-10-10, 1.16
496+
warnings.warn('np.asscalar(a) will be removed in v1.18 of numpy, use '
497+
'a.item() instead', DeprecationWarning, stacklevel=1)
489498
return a.item()
490499

491500
#-----------------------------------------------------------------------------

0 commit comments

Comments
 (0)