Skip to content

Commit 19eb179

Browse files
author
Hugues Devimeux
committed
fixed tuples in hashing, but converting them to lists
1 parent 037c9be commit 19eb179

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

manim/utils/hashing.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,10 @@ def _iter_check_list(lst):
111111
# We have to make a copy, as we don't want to touch to the original list
112112
# A deepcopy isn't necessary as it is already recursive.
113113
lst_copy = copy.copy(lst)
114+
if isinstance(lst, tuple):
115+
# NOTE : Sometimes a tuple can pass through this function. As a tuple is unmutable, we convert it to a list to be able to modify it.
116+
# It's ok as it's a copy.
117+
lst_copy = list(lst_copy)
114118
for i, el in enumerate(lst):
115119
if not isinstance(lst, tuple):
116120
lst_copy[i] = self._handle_already_processed(

tests/test_hashing.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,3 +108,9 @@ def test_JSON_with_big_np_array():
108108
a = np.zeros((1000, 1000))
109109
o_ser = hashing.get_json(a)
110110
assert "TRUNCATED ARRAY" in o_ser
111+
112+
113+
def test_JSON_with_tuple():
114+
o = [(1, [1])]
115+
o_ser = hashing.get_json(o)
116+
assert o_ser == "[[1, [1]]]"

0 commit comments

Comments
 (0)