Skip to content

Commit 07343cc

Browse files
authored
Merge pull request #498 from huguesdevimeux/fix-tuple-caching
FIX : fixed tuples in hashing, by converting them to lists
2 parents c7fa8fc + 9380036 commit 07343cc

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

manim/utils/hashing.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,11 @@ 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
116+
# is immutable, we convert it to a list to be able to modify it.
117+
# It's ok as it is a copy.
118+
lst_copy = list(lst_copy)
114119
for i, el in enumerate(lst):
115120
if not isinstance(lst, tuple):
116121
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)