qiskit
qiskit copied to clipboard
Create option for measures without arrows in mpl and text circuit drawers
Summary
Fixes #4149 Fixes #11895 Fixes #13581
Details and comments
This PR adds an option to the mpl and text drawers, measure_arrows, which will allow measures to be shown with or without the arrows pointing down to the clbits. If True, the default, the behavior will be exactly as it was before this PR. If False, the arrows will not be shown and instead the clbit name will be shown inside the measure box. This will allow measures to appear in the same layer, especially on a measure_all at the end of a circuit, the measures will stack on top of one another.
There is now a user_config option, circuit_measure_arrows which can be added to the user's config file if the user wants to default the option to False.
In some cases, especially in the text drawer, the measures may take up more room when the option is False due to the need to put the register/clbit name in the measure box.
Some examples,
qr = QuantumRegister(3, "qr")
cr = ClassicalRegister(3, "c")
qc = QuantumCircuit(qr, cr)
qc.x(0)
qc.h(0)
qc.measure(0, 0)
qc.x(1)
qc.h(1)
qc.measure(1, 1)
qc.x(2)
qc.h(2)
qc.measure(2, 2)
qc.draw(measure_arrows=False)
┌───┐┌───┐┌───────┐
qr_0: ┤ X ├┤ H ├┤ M-c_0 ├
├───┤├───┤├───────┤
qr_1: ┤ X ├┤ H ├┤ M-c_1 ├
├───┤├───┤├───────┤
qr_2: ┤ X ├┤ H ├┤ M-c_2 ├
└───┘└───┘└───────┘
c: 3/═══════════════════
One or more of the following people are relevant to this code:
- @enavarro51
@Qiskit/terra-core
Pull Request Test Coverage Report for Build 15744321646
Warning: This coverage report may be inaccurate.
This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
- For more information on this, see Tracking coverage changes with pull request builds.
- To avoid this issue with future PRs, see these Recommended CI Configurations.
- For a quick fix, rebase this PR at GitHub. Your next report should be accurate.
Details
- 30 of 53 (56.6%) changed or added relevant lines in 5 files are covered.
- 864 unchanged lines in 19 files lost coverage.
- Overall coverage remained the same at 88.009%
| Changes Missing Coverage | Covered Lines | Changed/Added Lines | % |
|---|---|---|---|
| qiskit/visualization/circuit/_utils.py | 11 | 12 | 91.67% |
| qiskit/visualization/circuit/text.py | 9 | 10 | 90.0% |
| qiskit/user_config.py | 3 | 6 | 50.0% |
| qiskit/visualization/circuit/matplotlib.py | 4 | 22 | 18.18% |
| <!-- | Total: | 30 | 53 |
| Files with Coverage Reduction | New Missed Lines | % |
|---|---|---|
| crates/qasm2/src/expr.rs | 1 | 94.23% |
| qiskit/circuit/_classical_resource_map.py | 1 | 75.0% |
| qiskit/circuit/annotation.py | 2 | 95.56% |
| qiskit/synthesis/boolean/boolean_expression.py | 2 | 96.7% |
| qiskit/visualization/circuit/matplotlib.py | 3 | 48.16% |
| crates/circuit/src/symbol_expr.rs | 4 | 73.81% |
| crates/circuit/src/lib.rs | 6 | 95.0% |
| crates/qasm2/src/lex.rs | 6 | 92.48% |
| qiskit/providers/backend.py | 6 | 91.43% |
| crates/circuit/src/classical/expr/var.rs | 7 | 93.4% |
| <!-- | Total: | 864 |
| Totals | |
|---|---|
| Change from base Build 15687720415: | 0.0% |
| Covered Lines: | 84032 |
| Relevant Lines: | 95481 |
💛 - Coveralls
Thanks, Raynel. My 100th merged PR. Some kind of milestone, I guess.