3b1b/manim · error · Exception
DieFace only accepts integer inputs between 1 and 6
Error message
DieFace only accepts integer inputs between 1 and 6
What it means
Raised by DieFace.__init__ (drawings.py:711) when the value argument falls outside 1..6. The class indexes a fixed six-entry pip-arrangement table with value - 1, so any other integer (or non-integer) is rejected before indexing.
Source
Thrown at manimlib/mobject/svg/drawings.py:711
stroke_color: ManimColor = WHITE,
stroke_width: float = 2.0,
fill_color: ManimColor = GREY_E,
dot_radius: float = 0.08,
dot_color: ManimColor = WHITE,
dot_coalesce_factor: float = 0.5
):
dot = Dot(radius=dot_radius, fill_color=dot_color)
square = Square(
side_length=side_length,
stroke_color=stroke_color,
stroke_width=stroke_width,
fill_color=fill_color,
fill_opacity=1.0,
)
square.round_corners(corner_radius)
if not (1 <= value <= 6):
raise Exception("DieFace only accepts integer inputs between 1 and 6")
edge_group = [
(ORIGIN,),
(UL, DR),
(UL, ORIGIN, DR),
(UL, UR, DL, DR),
(UL, UR, ORIGIN, DL, DR),
(UL, UR, LEFT, RIGHT, DL, DR),
][value - 1]
arrangement = VGroup(*(
dot.copy().move_to(square.get_bounding_box_point(vect))
for vect in edge_group
))
arrangement.space_out_submobjects(dot_coalesce_factor)
super().__init__(square, arrangement)
self.dots = arrangementView on GitHub (pinned to dee01804d4)
Solutions
- Clamp or re-map the value into 1..6 before constructing: value = min(max(value, 1), 6)
- Fix random generation: random.randint(1, 6), not randrange(7) or randint(1, 8)
- For counts above six, use a different mobject (e.g. a Square with a Tex label) instead of DieFace
Example fix
# before face = DieFace(random.randrange(7)) # can be 0 -> raises # after face = DieFace(random.randint(1, 6))
Defensive patterns
Strategy: validation
Validate before calling
value = int(value)
if not 1 <= value <= 6:
raise ValueError(f'DieFace value must be 1..6, got {value}')
face = DieFace(value) Prevention
- Use random.randint(1, 6) — not randrange(7) or randint(1, 8)
- Clamp external inputs to 1..6 before constructing DieFace
- For pip counts above six, use a Square with a Tex label instead
When it happens
Trigger: DieFace(0), DieFace(7), or DieFace(value) with a value from random.randint(1, 8) / user input that escaped the range; also non-integers like DieFace(3.5) fail the comparison chain (1 <= 3.5 <= 6 is True, but then value - 1 = 2.5 breaks list indexing with a TypeError instead).
Common situations: Simulating dice with randrange bounds off by one (randrange(7) yields 0..6); passing a configurable 'number of pips' that can exceed six; using DieFace to render generic counters.
Related errors
- Unsupported: {path_verb}
- At least 2 mobjects needed for Union.
- At least 2 mobjects needed for Intersection.
- At least 2 mobjects needed for Exclusion.
- tip not found
AI-assisted analysis of 3b1b/manim@dee01804d4 (2026-08-14).
Data as JSON: /api/errors/9a4955085fdc1394.
Report an issue: GitHub.