File tree 1 file changed +7
-5
lines changed
packages/python/plotly/_plotly_utils
1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -43,16 +43,18 @@ def to_typed_array_spec(v):
43
43
"""
44
44
v = copy_to_readonly_numpy_array (v )
45
45
46
+ # Skip b64 encoding if numpy is not installed,
47
+ # or if v is not a numpy array, or if v is empty
46
48
np = get_module ("numpy" , should_load = False )
47
- if not np or not isinstance (v , np .ndarray ):
49
+ if not np or not isinstance (v , np .ndarray ) or v . size == 0 :
48
50
return v
49
51
50
52
dtype = str (v .dtype )
51
53
52
54
# convert default Big Ints until we could support them in plotly.js
53
55
if dtype == "int64" :
54
- max = v .max () if v . size > 0 else 0
55
- min = v .min () if v . size > 0 else 0
56
+ max = v .max ()
57
+ min = v .min ()
56
58
if max <= int8max and min >= int8min :
57
59
v = v .astype ("int8" )
58
60
elif max <= int16max and min >= int16min :
@@ -63,8 +65,8 @@ def to_typed_array_spec(v):
63
65
return v
64
66
65
67
elif dtype == "uint64" :
66
- max = v .max () if v . size > 0 else 0
67
- min = v .min () if v . size > 0 else 0
68
+ max = v .max ()
69
+ min = v .min ()
68
70
if max <= uint8max and min >= 0 :
69
71
v = v .astype ("uint8" )
70
72
elif max <= uint16max and min >= 0 :
You can’t perform that action at this time.
0 commit comments