Skip to content

Commit ac9ddce

Browse files
committed
handle dtype conversion for empty arrays; check array.size
1 parent f824169 commit ac9ddce

File tree

1 file changed

+4
-4
lines changed
  • packages/python/plotly/_plotly_utils

1 file changed

+4
-4
lines changed

packages/python/plotly/_plotly_utils/utils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ def to_typed_array_spec(v):
5151

5252
# convert default Big Ints until we could support them in plotly.js
5353
if dtype == "int64":
54-
max = v.max() if v else 0
55-
min = v.min() if v else 0
54+
max = v.max() if v.size > 0 else 0
55+
min = v.min() if v.size > 0 else 0
5656
if max <= int8max and min >= int8min:
5757
v = v.astype("int8")
5858
elif max <= int16max and min >= int16min:
@@ -63,8 +63,8 @@ def to_typed_array_spec(v):
6363
return v
6464

6565
elif dtype == "uint64":
66-
max = v.max() if v else 0
67-
min = v.min() if v else 0
66+
max = v.max() if v.size > 0 else 0
67+
min = v.min() if v.size > 0 else 0
6868
if max <= uint8max and min >= 0:
6969
v = v.astype("uint8")
7070
elif max <= uint16max and min >= 0:

0 commit comments

Comments
 (0)