{"record":{"id":"3e38bc4c92d96fe5","repo":"3b1b/manim","slug":"invalid-input-sample-type","errorCode":null,"errorMessage":"Invalid input sample type","messagePattern":"Invalid input sample type","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"manimlib/mobject/coordinate_systems.py","lineNumber":395,"sourceCode":"        if x_range is None:\n            x_range = self.x_range[:2]\n        if dx is None:\n            dx = self.x_range[2]\n        if len(x_range) < 3:\n            x_range = [*x_range, dx]\n\n        rects = []\n        x_range[1] = x_range[1] + dx\n        xs = np.arange(*x_range)\n        for x0, x1 in zip(xs, xs[1:]):\n            if input_sample_type == \"left\":\n                sample = x0\n            elif input_sample_type == \"right\":\n                sample = x1\n            elif input_sample_type == \"center\":\n                sample = 0.5 * x0 + 0.5 * x1\n            else:\n                raise Exception(\"Invalid input sample type\")\n            height_vect = self.i2gp(sample, graph) - self.c2p(sample, 0)\n            rect = Rectangle(\n                width=self.x_axis.n2p(x1)[0] - self.x_axis.n2p(x0)[0],\n                height=get_norm(height_vect),\n            )\n            rect.positive = height_vect[1] > 0\n            rect.move_to(self.c2p(x0, 0), DL if rect.positive else UL)\n            rects.append(rect)\n        result = VGroup(*rects)\n        result.set_submobject_colors_by_gradient(*colors)\n        result.set_style(\n            stroke_width=stroke_width,\n            stroke_color=stroke_color,\n            fill_opacity=fill_opacity,\n            stroke_behind=stroke_background\n        )\n        for rect in result:\n            if not rect.positive:","sourceCodeStart":377,"sourceCodeEnd":413,"githubUrl":"https://github.com/3b1b/manim/blob/dee01804d47b9f94402d71472674710dcac125b8/manimlib/mobject/coordinate_systems.py#L377-L413","documentation":"Exception('Invalid input sample type') raised in Axes.get_riemann_rectangles (manimlib/mobject/coordinate_systems.py:395). The input_sample_type keyword controls where each rectangle samples the function height and only accepts exactly 'left', 'right', or 'center'; any other string (or typo/case variant) reaches the else branch.","triggerScenarios":"Calling get_riemann_rectangles(..., input_sample_type='midpoint'), 'Center', 'LEFT', or any non-literal string; passing a variable whose value drifted from the three allowed literals.","commonSituations":"Math convention mismatch: users write 'midpoint' or 'middle' instead of 'center'; case-sensitive copies from other libraries (matplotlib's density args); typos in scene config files.","solutions":["Use one of the exact literals: \"left\", \"right\", or \"center\"","Normalize input before the call: value = value.strip().lower() and validate against {'left','right','center'}","If a custom sample point is needed, write your own rectangle loop using i2gp instead of relying on input_sample_type"],"exampleFix":"# before\nrects = axes.get_riemann_rectangles(graph, input_sample_type=\"midpoint\")\n\n# after\nrects = axes.get_riemann_rectangles(graph, input_sample_type=\"center\")","handlingStrategy":"validation","validationCode":"VALID = {\"left\", \"right\", \"center\"}\nsample_type = str(user_input).strip().lower()\nassert sample_type in VALID, f\"input_sample_type must be one of {VALID}, got {user_input!r}\"\nrects = axes.get_riemann_rectangles(graph, input_sample_type=sample_type)","typeGuard":"def is_valid_sample_type(value: str) -> bool:\n    return value in {\"left\", \"right\", \"center\"}","tryCatchPattern":null,"preventionTips":["Use typing.Literal['left','right','center'] in wrappers to get static checking","Remember 'center' is the midpoint option; 'midpoint' is not accepted"],"tags":["manim","coordinate-systems","riemann-sums","validation"],"backgroundTag":null,"analyzedSha":"dee01804d47b9f94402d71472674710dcac125b8","analyzedAt":"2026-08-14T19:53:44.241Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}