A community-maintained Python framework for creating mathematical animations.
fixed tuples in hashing, but converting them to lists
Hugues Devimeux19eb1792be72
diff --git a/manim/utils/hashing.py b/manim/utils/hashing.pyindex ee79effef..b17cbe532 100644--- a/manim/utils/hashing.py+++ b/manim/utils/hashing.py@@ -111,6 +111,10 @@ class CustomEncoder(json.JSONEncoder):# We have to make a copy, as we don't want to touch to the original list# A deepcopy isn't necessary as it is already recursive.lst_copy = copy.copy(lst)+ if isinstance(lst, tuple):+ # 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.+ # It's ok as it's a copy.+ lst_copy = list(lst_copy)for i, el in enumerate(lst):if not isinstance(lst, tuple):lst_copy[i] = self._handle_already_processed(diff --git a/tests/test_hashing.py b/tests/test_hashing.pyindex aa295415e..2a839dd20 100644--- a/tests/test_hashing.py+++ b/tests/test_hashing.py@@ -108,3 +108,9 @@ def test_JSON_with_big_np_array():a = np.zeros((1000, 1000))o_ser = hashing.get_json(a)assert "TRUNCATED ARRAY" in o_ser+++def test_JSON_with_tuple():+ o = [(1, [1])]+ o_ser = hashing.get_json(o)+ assert o_ser == "[[1, [1]]]"