Skip to content

Commit 73995e3

Browse files
malmaudjonmmease
authored andcommitted
Use '.item' instead of the deprecated 'asscalar'. (#1428)
1 parent 63c8ecf commit 73995e3

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

Diff for: _plotly_utils/basevalidators.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,9 @@ def to_scalar_or_list(v):
4949
# 0-dimensional array, but we instead want it converted to a
5050
# Python native scalar type ('float' in the example above).
5151
# We explicitly check if is has the 'item' method, which conventionally
52-
# converts these types to native scalars. This guards against 'v' already being
53-
# a Python native scalar type since `numpy.isscalar` would return
54-
# True but `numpy.asscalar` will (oddly) raise an error is called with a
55-
# a native Python scalar object.
52+
# converts these types to native scalars.
5653
if np and np.isscalar(v) and hasattr(v, 'item'):
57-
return np.asscalar(v)
54+
return v.item()
5855
if isinstance(v, (list, tuple)):
5956
return [to_scalar_or_list(e) for e in v]
6057
elif np and isinstance(v, np.ndarray):

0 commit comments

Comments
 (0)