Skip to content

MLP221: literal range step proves an excessive sample count

qual reports MLP221 when the literal three-element t_range / x_range of a ParametricFunction(...) / axes.plot(...) call proves an excessive sample count: generate_points samples np.arange(t_min, t_max, t_step) and (unless vectorized) calls the plotted Python function once per sample, then smoothing post-processes every stored point (functions.py).

  • Default severity: warning
  • Minimum confidence: high
  • Implementation phase: 3
  • Fix: none

Threshold (documented constant in rules/performance/sampling.rs):

  • MLP221_SAMPLE_GATE = N_samples >= 10000 — interval-evaluated as ceil((end - start) / step) from int / float literals only. Two element ranges, non-literal elements, non-positive steps, and empty spans are never guessed.

Resolution basis (the ids are not curated in upstream_0_20 yet): a candidate is accepted when the knowledge profile resolves it, or when the frontend's import resolution produced exactly the canonical module path (manim.mobject.graphing.functions.ParametricFunction, or plot on a tracked instance of the canonical Axes class). Name-string guessing never happens; the star-import alias stays silent until the profile curates the export.

use_vectorized=True is mentioned only as a note, and only when the function consists of NumPy ufuncs — arbitrary Python callbacks must not be vectorized automatically (DESIGN 7.3).

Wrong

curve = ParametricFunction(spiral, t_range=(0, 50, 0.0001))   # ~500000 samples
graph = axes.plot(f, x_range=[-10, 10, 0.00005])              # ~400000 samples
curve = ParametricFunction(spiral, t_range=(0, 50, 0.01))     # ~5000 samples
graph = axes.plot(f, x_range=[-10, 10, 0.01])                 # ~2000 samples