Skip to content

MLR121: shift(OUT)/set_z for stacking order in a 2D Cairo scene

qual reports MLR121 when a method of a plain-camera (2D) scene calls shift(OUT) or set_z(<literal>) on a confirmed mobject while a Cairo profile is active.

  • Default severity: warning
  • Minimum confidence: high
  • Implementation phase: 4
  • Fix: none (suggests set_z_index)

In a 2D Cairo scene the z coordinate does nothing: the plain Camera projects points using only their x/y components (camera.py points_to_subpixel_coords), and the display order is the family list stable-sorted by z_index (utils/family.py extract_mobject_family_members). Moving a mobject along OUT (or setting its z coordinate) changes neither its position on screen nor its stacking, so the intended overlap fix never happens — set_z_index is the API that participates in the display-order sort.

Conservative subset: the call must sit inside a scene whose camera contract is definitely Standard, the receiver must be a confirmed mobject, and the argument must be the literal curated OUT constant (never re-bound in the file) or a numeric literal for set_z. ThreeDScene / MovingCameraScene / unknown-camera scenes, arithmetic like 2 * OUT, project overrides of set_z, and OpenGL-only runs stay silent; applicable_profiles lists the Cairo profiles (DESIGN 15.8).

Wrong:

class OverlapScene(Scene):
    def construct(self):
        circle.shift(OUT)  # no visual effect in 2D Cairo

Right:

class OverlapScene(Scene):
    def construct(self):
        circle.set_z_index(1)