-
Notifications
You must be signed in to change notification settings - Fork 1.1k
use str
instead of repr
for tags in circuit diagram
#6411
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Another possibility would be to allow tags to implement some protocol method to produce a more compact representation for circuit diagrams. Something like |
that would definitely be the nicest solution, in that it could also support e.g. i still think it would make sense to fall back on class Foo(cirq.Gate):
def _num_qubits_(self): return 1
def __str__(self): return "<str>"
def __repr__(self): return "<repr>"
print(cirq.Circuit(Foo().on(cirq.q(0)))) # prints "0: ───<str>───" It also seems more in keeping with the goal of the circuit diagram generally - usually the point of implementing |
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days |
This is AL from the CirqCync - please assign to me |
^ i actually have a working version of this locally i can push :) it just uses |
Hey @xXxH3LIOSxXx , Please review #6530 if you can. |
Thank you @richrines1 and @xXxH3LIOSxXx for helping to improve this. |
Done - #6560 |
Continued as #6560. Anyone interested (@xXxH3LIOSxXx, @richrines1) , please feel free to comment there if you'd like to take it on. Thank you! |
…ib#6530) Use more readable rendering of tagged operations in diagrams. Fixes: quantumlib#6411
…ib#6530) Use more readable rendering of tagged operations in diagrams. Fixes: quantumlib#6411
Is your feature request related to a use case or problem? Please describe.
currently tags are displayed in circuit diagrams via their
repr
(implicitly viastr(list(tags))
). This can lead to some unruly or hard-to-read circuit diagrams, e.g.:this could be cleaned up by overriding
tag.__repr__
, but usually not without breaking the expectation thateval(repr(tagged_op)) == tagged_op
Describe the solution you'd like
it seems like it'd be much more natural (and easier to customize) if the circuit diagram drawer to instead use the tags' strings, e.g.:
What is the urgency from your perspective for this issue? Is it blocking important work?
P3 - I'm not really blocked by it, it is an idea I'd like to discuss / suggestion based on principle
(happy to work on this if it seems reasonable)
The text was updated successfully, but these errors were encountered: