Improved text drawing for dynamically allocated wires#9545
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #9545 +/- ##
=======================================
Coverage 99.45% 99.45%
=======================================
Files 611 611
Lines 67612 67701 +89
=======================================
+ Hits 67241 67330 +89
Misses 371 371 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Co-authored-by: Yushao Chen (Jerry) <chenys13@outlook.com>
astralcai
left a comment
There was a problem hiding this comment.
LGTM! The new circuit drawings look really nice now.
| qp.cond(m, qp.X)(0) | ||
|
|
||
| out = qp.draw(f)() | ||
| # fmt: off |
There was a problem hiding this comment.
Oh wow, didn't know you could do that.
There was a problem hiding this comment.
Should we handle other places where config.n_wires should be used in this PR or a follow-up one
There was a problem hiding this comment.
Like, _add_cond_grouping_symbols, _add_mid_measure_grouping_symbol etc.
There was a problem hiding this comment.
WHY SO MANY CASES!!!!
def f():
m = qp.measure(0)
with qp.allocate(1) as wires:
qp.cond(m, qp.CNOT)((0,1))
qp.H(0)
qp.H(0)
with qp.allocate(1) as wires:
qp.cond(m, qp.CZ)((0,1))
print(qp.draw(f)())
good catch./
There was a problem hiding this comment.
Do you know which ones are in the etc? That would help tremendously.
There was a problem hiding this comment.
_add_subroutine_mcm_grouping_symbols
_add_cwire_measurement_grouping_symbols
So basically searching len(config.wire_map) within this file reveals them
Context:
Inspecting circuits with draw and allocations is really ugly and hard to read. This improves that.
Description of the Change:
Adds handling for allowing quantum wires to have limited extent. Tries to reuse horizontal lines for multiple allocations if possible.
Benefits:
Easier inspection of circuits.
Possible Drawbacks:
Related GitHub Issues:
[sc-120927]