-
Notifications
You must be signed in to change notification settings - Fork 21
Pretty print #245
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
base: master
Are you sure you want to change the base?
Pretty print #245
Conversation
…ng: see tests_patterns, tests_tnsim and tests_transpiler
graphix/pattern.py
Outdated
import PIL | ||
|
||
try: | ||
subprocess.run( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you looked for latex wrappers? I feel the approach here (raw subprocess call) is a little bit too direct.
graphix/pattern.py
Outdated
|
||
output.write(self.to_latex(left_to_right)) | ||
|
||
output.write("\n\\end{document}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Raw string
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Beware that \n
is an escape form.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, but still it sounds odd that we need to manually input \n
. This may be avoided by connecting print
to the output
instance.
@benjvmin93 Could you turn on ruff rule |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are still some fixes needed, and I made some remarks to clean the code and make it more general.
graphix/pattern.py
Outdated
|
||
output.write(self.to_latex(left_to_right)) | ||
|
||
output.write("\n\\end{document}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Beware that \n
is an escape form.
"""Return a string representation of the Circuit.""" | ||
return self.draw() | ||
|
||
def draw(self, output: str = "text") -> TextDrawing | matplotlib.figure | PIL.Image | str: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand your argument. I think it would be more efficient if you provided a direct code suggestion, assuming you believe it's worthwhile.
Co-authored-by: thierry-martinez <[email protected]>
…presenting pi in the proper format
if possible, can we move the implementation of drawing methods out of |
@benjvmin93 (CC: @shinich1 ) Additionally, if you're planning to add bunch of features to Are there any updates on |
Before submitting, please check the following:
nox
)ruff
CONTRIBUTING.md
for more detailsThen, please fill in below:
Context (if applicable):
#239
Description of the change:
New
draw()
methods inCircuit
andPattern
classes.Circuit.draw()
generates the corresponding Qasm3 code and pass it toqiskit.draw()
method. It relates on the same arguments (seeqiskit.draw()
method documentation).pattern.draw()
locally generates the appropriate visualization object (in the ascii, unicode, png, or latex formats)pattern.__repr__()
returns the pythonic representation useful to initialize the same object. It involves handling__repr__
method for commands. Thus, directly related to the writing of aclass Command
.More details on the different changes are described in the
CHANGELOG.md
file.Related issue: