File tree 1 file changed +2
-5
lines changed
1 file changed +2
-5
lines changed Original file line number Diff line number Diff line change @@ -49,12 +49,9 @@ def to_scalar_or_list(v):
49
49
# 0-dimensional array, but we instead want it converted to a
50
50
# Python native scalar type ('float' in the example above).
51
51
# 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.
56
53
if np and np .isscalar (v ) and hasattr (v , 'item' ):
57
- return np . asscalar ( v )
54
+ return v . item ( )
58
55
if isinstance (v , (list , tuple )):
59
56
return [to_scalar_or_list (e ) for e in v ]
60
57
elif np and isinstance (v , np .ndarray ):
You can’t perform that action at this time.
0 commit comments