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

Skip to content

Commit bcbdc4f

Browse files
committed
make sure numpy is loaded when processing a numpy convertible array
1 parent be1c4ed commit bcbdc4f

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

packages/python/plotly/_plotly_utils/basevalidators.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -177,12 +177,14 @@ def is_homogeneous_array(v):
177177
):
178178
return True
179179
if is_numpy_convertable(v):
180-
v_numpy = np.array(v)
181-
# v is essentially a scalar and so shouldn't count as an array
182-
if v_numpy.shape == ():
183-
return False
184-
else:
185-
return True
180+
np = get_module("numpy", should_load=True)
181+
if np:
182+
v_numpy = np.array(v)
183+
# v is essentially a scalar and so shouldn't count as an array
184+
if v_numpy.shape == ():
185+
return False
186+
else:
187+
return True
186188
return False
187189

188190

0 commit comments

Comments
 (0)