Skip to content

Commit 27d4177

Browse files
author
Jon M. Mease
committed
Handle recursive equality of lists, tuples, and dicts that contain numpy arrays
1 parent a3b390e commit 27d4177

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Diff for: plotly/basedatatypes.py

+10
Original file line numberDiff line numberDiff line change
@@ -1414,6 +1414,16 @@ def _in_batch_mode(self):
14141414
def _vals_equal(v1, v2):
14151415
if isinstance(v1, np.ndarray) or isinstance(v2, np.ndarray):
14161416
return np.array_equal(v1, v2)
1417+
elif isinstance(v1, (list, tuple)):
1418+
# Handle recursive equality on lists and tuples
1419+
return (isinstance(v2, (list, tuple)) and
1420+
len(v1) == len(v2) and
1421+
all(BasePlotlyType._vals_equal(e1, e2) for e1, e2 in zip(v1, v2)))
1422+
elif isinstance(v1, dict):
1423+
# Handle recursive equality on dicts
1424+
return (isinstance(v2, dict) and
1425+
set(v1.keys()) == set(v2.keys()) and
1426+
all(BasePlotlyType._vals_equal(v1[k], v2[k])) for k in v1)
14171427
else:
14181428
return v1 == v2
14191429

0 commit comments

Comments
 (0)