From 19eb1792be72b7512324276a6dfb7b8e0c638d5e Mon Sep 17 00:00:00 2001 From: Hugues Devimeux Date: Thu, 1 Oct 2020 09:16:33 +0200 Subject: [PATCH 1/4] fixed tuples in hashing, but converting them to lists --- manim/utils/hashing.py | 4 ++++ tests/test_hashing.py | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/manim/utils/hashing.py b/manim/utils/hashing.py index ee79effef3..b17cbe5321 100644 --- a/manim/utils/hashing.py +++ b/manim/utils/hashing.py @@ -111,6 +111,10 @@ def _iter_check_list(lst): # 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.py index aa295415ee..2a839dd20c 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]]]" From cc94d6bcf620bb20cc5a6acef684e2bed59f2b33 Mon Sep 17 00:00:00 2001 From: Hugues Devimeux Date: Thu, 1 Oct 2020 09:55:24 +0200 Subject: [PATCH 2/4] Trigger tests From 538f4746f7a17bd74e82f1feb1625c544bc5003d Mon Sep 17 00:00:00 2001 From: Hugues Devimeux <36239975+huguesdevimeux@users.noreply.github.com> Date: Thu, 1 Oct 2020 09:56:30 +0200 Subject: [PATCH 3/4] Update manim/utils/hashing.py Co-authored-by: kilacoda <65204531+kilacoda@users.noreply.github.com> --- manim/utils/hashing.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manim/utils/hashing.py b/manim/utils/hashing.py index b17cbe5321..abd5b03ca1 100644 --- a/manim/utils/hashing.py +++ b/manim/utils/hashing.py @@ -112,7 +112,7 @@ def _iter_check_list(lst): # 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. + # NOTE : Sometimes a tuple can pass through this function. As a tuple is immutable, 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): From 9380036a276a72245259ab7a998190acaafbcec0 Mon Sep 17 00:00:00 2001 From: Hugues Devimeux <36239975+huguesdevimeux@users.noreply.github.com> Date: Sat, 3 Oct 2020 13:54:11 +0200 Subject: [PATCH 4/4] Update manim/utils/hashing.py Co-authored-by: Benjamin Hackl --- manim/utils/hashing.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/manim/utils/hashing.py b/manim/utils/hashing.py index abd5b03ca1..471b01893a 100644 --- a/manim/utils/hashing.py +++ b/manim/utils/hashing.py @@ -112,8 +112,9 @@ def _iter_check_list(lst): # 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 immutable, we convert it to a list to be able to modify it. - # It's ok as it's a copy. + # NOTE: Sometimes a tuple can pass through this function. As a tuple + # is immutable, we convert it to a list to be able to modify it. + # It's ok as it is a copy. lst_copy = list(lst_copy) for i, el in enumerate(lst): if not isinstance(lst, tuple):