Skip to content

REV_CTRL_GATE_MAP missing mirror entries for c3x/c4x breaks matplotlib printer #322

Description

@TheGupta2012

Problem

CTRL_GATE_MAP in src/pyqasm/maps/gates.py contains:

  • "ccx": "c3x"
  • "c3x": "c4x"

But the inverse REV_CTRL_GATE_MAP (lines 1217-1229) is missing the mirror entries:

  • "c3x": "ccx"
  • "c4x": "c3x"

Impact

REV_CTRL_GATE_MAP is consumed by src/pyqasm/printer.py:516-523 (_mpl_draw_gate), which peels off controls one level at a time to draw the base gate plus control dots. A user who loads a circuit containing c3x/c4x (without unrolling) and tries to visualise it via the matplotlib printer falls through to raise NotImplementedError(f\"Unsupported gate: {name}\") at printer.py:533.

Suggested fix

Add the two mirror entries to REV_CTRL_GATE_MAP so the maps stay symmetric, plus a small printer round-trip test for c3x/c4x to lock it in.

Context

Surfaced during review of #320, which made c3x/c4x first-class gates and thus made this latent gap user-reachable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions