Skip to content

Commit

Permalink
phase placeholder
Browse files Browse the repository at this point in the history
  • Loading branch information
arulandu committed Jan 17, 2025
1 parent 5575332 commit f6d4d77
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/pyqasm/printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ def _draw_mpl(module: Qasm3Module, idle_wires=True) -> plt.Figure:
depth = 1 + max(depths[qubit_key], depths[target_key])
for k in [qubit_key, target_key]:
depths[k] = depth
elif isinstance(statement, ast.QuantumPhase):
qubits = [_identifier_to_key(q) for q in statement.qubits]
if len(qubits) > 0:
depth = 1 + max([depths[q] for q in qubits])
for q in qubits:
depths[q] = depth
elif isinstance(statement, ast.QuantumBarrier):
qubits = [_identifier_to_key(q) for q in statement.qubits]
depth = 1 + max([depths[q] for q in qubits])
Expand Down Expand Up @@ -284,6 +290,9 @@ def _mpl_draw_statement(
_mpl_draw_measurement(
line_nums[qubit_key], line_nums[(target_key[0], -1)], target_key[1], ax, x
)
elif isinstance(statement, ast.QuantumPhase):
# TODO: draw gphase
pass
elif isinstance(statement, ast.QuantumBarrier):
lines = [line_nums[_identifier_to_key(q)] for q in statement.qubits]
_mpl_draw_barrier(lines, ax, x)
Expand Down
2 changes: 1 addition & 1 deletion tests/qasm3/test_printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def test_custom_gate():
_check_fig(circ, fig)


@pytest.mark.parametrize("_", range(10))
@pytest.mark.parametrize("_", range(100))
def test_random(_):
circ = random_circuit("qiskit", measure=random.choice([True, False]))
qasm_str = transpile(circ, random.choice(["qasm2", "qasm3"]))
Expand Down

0 comments on commit f6d4d77

Please sign in to comment.