Skip to content

FIX : fixed tuples in hashing, by converting them to lists #498

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Oct 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions manim/utils/hashing.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@ 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 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):
lst_copy[i] = self._handle_already_processed(
Expand Down
6 changes: 6 additions & 0 deletions tests/test_hashing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]]]"