manim icon indicating copy to clipboard operation
manim copied to clipboard

Regression in v0.20: `Integer`/`DecimalNumber` animations crash with "ValueError: zip() argument 2 is longer than argument 1" when the number of digits changes

Open ashlanserrao opened this issue 2 weeks ago • 0 comments

Description of bug / unexpected behavior

Animating an Integer / DecimalNumber to a value with a different number of digits crashes when the animation is a Transform subclass. Examples are .animate.set_value(...), or FadeIn running at the same time as ChangeDecimalToValue:

ValueError: zip() argument 2 is longer than argument 1

(or ... is shorter than argument 1, depending on whether the digit count goes down or up).

This is a regression. Both examples below render correctly on v0.19.2 and crash on v0.20.1 and v0.22.1 (latest).

Expected behavior

Same as v0.19.2. The number animates to the new value without an error:

  • Example 1 ends showing 0.
  • Example 2 ends showing the square with 100.00 inside.

How to reproduce the issue

Code for reproducing the problem

Example 1, .animate.set_value() going from 2 digits to 1 (manim -ql repro.py Repro):

from manim import *

class Repro(Scene):
    def construct(self):
        n = Integer(10)
        self.add(n)
        self.play(n.animate.set_value(0))

Example 2, FadeIn on a group plus ChangeDecimalToValue on a number inside it (manim -ql repro.py Repro2). This one crashes partway through the animation, around the moment the number gains a digit:

from manim import *

class Repro2(Scene):
    def construct(self):
        d = DecimalNumber(0)
        g = VGroup(Square(), d)
        self.play(FadeIn(g), ChangeDecimalToValue(d, 100))

Additional media files

Images/GIFs

No media: the render aborts with the error below. (On v0.19.2 the last frames are 0 and the square with 100.00 respectively.)

Logs

Terminal output

Example 1 on v0.22.1 (plain Python traceback; site-packages paths shortened):

  File "repro.py", line 10, in construct
    self.play(n.animate.set_value(0))
  File ".../manim/scene/scene.py", line 1234, in play
    self._get_manager().play(
  File ".../manim/manager.py", line 260, in play
    self.renderer.play(self.scene, *args, **kwargs)
  File ".../manim/renderer/cairo_renderer.py", line 134, in play
    scene.play_internal()
  File ".../manim/scene/scene.py", line 1410, in play_internal
    animation.finish()
  File ".../manim/animation/transform.py", line 451, in finish
    super().finish()
  File ".../manim/animation/animation.py", line 225, in finish
    self.interpolate(1)
  File ".../manim/animation/animation.py", line 337, in interpolate
    self.interpolate_mobject(alpha)
  File ".../manim/animation/animation.py", line 349, in interpolate_mobject
    families = list(self.get_all_families_zipped())
ValueError: zip() argument 2 is longer than argument 1

Example 2 on v0.22.1:

  File "repro.py", line 19, in construct
    self.play(FadeIn(g), ChangeDecimalToValue(d, 100))
  File ".../manim/scene/scene.py", line 1234, in play
    self._get_manager().play(
  File ".../manim/manager.py", line 260, in play
    self.renderer.play(self.scene, *args, **kwargs)
  File ".../manim/renderer/cairo_renderer.py", line 134, in play
    scene.play_internal()
  File ".../manim/scene/scene.py", line 1402, in play_internal
    self.update_to_time(t)
  File ".../manim/scene/scene.py", line 1721, in update_to_time
    animation.interpolate(alpha)
  File ".../manim/animation/animation.py", line 337, in interpolate
    self.interpolate_mobject(alpha)
  File ".../manim/animation/animation.py", line 349, in interpolate_mobject
    families = list(self.get_all_families_zipped())
ValueError: zip() argument 2 is shorter than argument 1

On v0.20.1 the same error is printed, but the render then hangs instead of exiting (already fixed by #4904).

System specifications

System Details
  • OS (with version, e.g., Windows 10 v2004 or macOS 10.15 (Catalina)): Windows 11 Home 10.0.26200 (64-bit)
  • RAM: 24 GB
  • Python version (python/py/python3 --version): 3.13.5
  • Installed modules (provide output from pip list): fresh venv with only pip install manim:
audioop-lts==0.2.2
av==19.0.2
beautifulsoup4==4.15.0
click==8.5.1
cloup==4.0.0
colorama==0.4.6
decorator==5.3.1
glcontext==3.1.0
isosurfaces==0.1.2
manim==0.22.1
ManimPango==0.7.1
mapbox_earcut==2.1.0
markdown-it-py==4.3.0
mdurl==0.1.2
moderngl==5.13.0
moderngl-window==3.1.1
networkx==3.7
numpy==2.5.5
pillow==13.0.0
pip==26.3
pycairo==1.29.2
pydub==0.25.1
pyglet==2.1.19
pyglm==2.8.3
Pygments==2.21.0
rich==15.0.0
scipy==1.18.1
screeninfo==0.8.1
skia-pathops==0.9.2
soupsieve==4.1.1
srt==3.5.3
svgelements==1.9.6
tqdm==4.70.1
typing_extensions==4.16.0
watchdog==7.1.0
LaTeX details
  • LaTeX distribution (e.g. TeX Live 2020): MiKTeX 25.12 (dvisvgm 3.4.3)
  • Installed LaTeX packages: default MiKTeX install. LaTeX isn't involved in the bug, because the same setup renders both examples fine on v0.19.2.

Additional comments

Likely cause: #4547 changed Transform.get_all_families_zipped (manim/animation/transform.py) from zip(..., strict=False) to zip(..., strict=True). It was first released in v0.20.0. The base Animation.get_all_families_zipped still uses strict=False.

When set_value (or a concurrent ChangeDecimalToValue) changes the number of digit submobjects, the families of mobject, starting_mobject and target_copy no longer have the same length, so the strict zip raises. .animate (_MethodAnimation) and FadeIn are both Transform subclasses.

Related: a review comment on #4913 mentions the same error for mob.animate.insert(...), and #4521 is the cleanup issue that led to #4547.

Workaround: ChangeDecimalToValue(n, 0) instead of n.animate.set_value(0) (for example 1).

I'd like to work on a fix for this, with a regression test. Simply reverting to strict=False would hide the error but may silently mis-pair submobjects, so I'll look into aligning the families properly. Happy to hear if maintainers prefer a particular approach.

ashlanserrao avatar Nov 17 '26 13:11 ashlanserrao