Skip to content

BUG : kwargs in ApplyMethod Breaks Scene Caching #491

Closed
@sudgy

Description

@sudgy
class IssueKwargsCache(Scene):
    def construct(self):
        m = Dot()
        self.play(ApplyMethod(m.scale, 2, {"about_point": RIGHT}))

When trying to run this scene, it breaks with this backtrace:

  File ".../manim/manim/__main__.py", line 170, in main
    scene = SceneClass()
  File ".../manim/manim/scene/scene.py", line 86, in __init__
    self.construct()
  File "intro.py", line 247, in construct
    self.play(ApplyMethod(v.scale, 0.5, {"about_point": v.get_start()}))
  File ".../manim/manim/scene/scene.py", line 818, in wrapper
    hash_play = get_hash_from_play_call(
  File ".../manim/manim/utils/hashing.py", line 240, in get_hash_from_play_call
    animations_list_json = [get_json(x) for x in sorted(animations_list, key=str)]
  File ".../manim/manim/utils/hashing.py", line 240, in <listcomp>
    animations_list_json = [get_json(x) for x in sorted(animations_list, key=str)]
  File ".../manim/manim/utils/hashing.py", line 185, in get_json
    return json.dumps(obj, cls=CustomEncoder)
  File "/usr/lib/python3.8/json/__init__.py", line 234, in dumps
    return cls(
  File ".../manim/manim/utils/hashing.py", line 169, in encode
    return super().encode(obj)
  File "/usr/lib/python3.8/json/encoder.py", line 199, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/usr/lib/python3.8/json/encoder.py", line 257, in iterencode
    return _iterencode(o, 0)
  File ".../manim/manim/utils/hashing.py", line 67, in default
    return self._check_iterable(temp)
  File ".../manim/manim/utils/hashing.py", line 148, in _check_iterable
    return _iter_check_dict(iterable)
  File ".../manim/manim/utils/hashing.py", line 142, in _iter_check_dict
    dct_copy[k_new] = _iter_check_list(v)
  File ".../manim/manim/utils/hashing.py", line 122, in _iter_check_list
    lst_copy[i] = _iter_check_dict(el)
TypeError: 'tuple' object does not support item assignment

And yes, huguesdevimeux, the problem disappears when --disable_caching is used.

Metadata

Metadata

Labels

pr:bugfixBug fix for use in PRs solving a specific issue:bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions