{"record":{"id":"d124edec382c2866","repo":"3b1b/manim","slug":"bezier-cannot-be-calld-on-an-empty-list","errorCode":null,"errorMessage":"bezier cannot be calld on an empty list","messagePattern":"bezier cannot be calld on an empty list","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"manimlib/utils/bezier.py","lineNumber":32,"sourceCode":"from manimlib.utils.space_ops import z_to_vector\n\nfrom typing import TYPE_CHECKING\n\nif TYPE_CHECKING:\n    from typing import Callable, Sequence, TypeVar, Tuple\n    from manimlib.typing import VectN, FloatArray, VectNArray, Vect3Array\n\n    Scalable = TypeVar(\"Scalable\", float, FloatArray)\n\n\nCLOSED_THRESHOLD = 0.001\n\n\ndef bezier(\n    points: Sequence[float | FloatArray] | VectNArray\n) -> Callable[[float], float | FloatArray]:\n    if len(points) == 0:\n        raise Exception(\"bezier cannot be calld on an empty list\")\n\n    n = len(points) - 1\n\n    def result(t: float) -> float | FloatArray:\n        return sum(\n            ((1 - t)**(n - k)) * (t**k) * choose(n, k) * point\n            for k, point in enumerate(points)\n        )\n\n    return result\n\n\ndef partial_bezier_points(\n    points: Sequence[Scalable],\n    a: float,\n    b: float\n) -> list[Scalable]:\n    \"\"\"","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/3b1b/manim/blob/dee01804d47b9f94402d71472674710dcac125b8/manimlib/utils/bezier.py#L14-L50","documentation":"Raised by bezier() (utils/bezier.py:32) when called with an empty sequence of control points. A Bezier curve needs at least one control point to evaluate the Bernstein-polynomial sum, so len(points) == 0 is rejected (note the typo 'calld' in the message).","triggerScenarios":"Directly calling bezier([]); indirectly, manim internals computing interpolants for a VMobject whose points list is empty (e.g. partial_bezier_points or get_..._interpolant on a degenerate mobject with no points).","commonSituations":"Feeding bezier() a slice that happens to be empty (points[i:j] with i >= j); operating on VMobjects created without points or after pointwise_become_partial with a==b producing empty slices.","solutions":["Guard the call site: if not points: return a constant (e.g. lambda t: 0.0) instead of invoking bezier()","Fix the slicing/index logic so the control-point list is never empty before calling bezier()","If it comes from a mobject with no points, initialize/retain points on the mobject (e.g. avoid a==b in partial ranges)"],"exampleFix":"# before\ncurve = bezier(points[start:end])  # start >= end -> empty -> raises\n\n# after\ncurve = bezier(points[start:end]) if start < end else (lambda t: points[start])","handlingStrategy":"validation","validationCode":"pts = points[start:end]\nif len(pts) == 0:\n    curve = lambda t: 0.0  # degenerate: no control points\nelse:\n    curve = bezier(pts)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never call bezier() without checking len(points) > 0","Guard slices: ensure start < end before slicing control-point lists","Avoid empty point arrays on mobjects passed to partial-interpolation utilities"],"tags":["manim","bezier","empty-list","math","guard"],"backgroundTag":null,"analyzedSha":"dee01804d47b9f94402d71472674710dcac125b8","analyzedAt":"2026-08-14T19:53:44.241Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}