-
Notifications
You must be signed in to change notification settings - Fork 575
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
Minor improvement to CircuitDrawer class interface #1640
Conversation
Co-authored-by: Josh Izaac <josh146@gmail.com>
Co-authored-by: Theodor <theodor@xanadu.ai>
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.
Looks good @albi3ro! 💯 Only one minor suggestion for the readability of the error message.
self.charset = charset | ||
|
||
if charset is None: | ||
self.charset = CHARSETS["unicode"]() |
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.
Is CHARSETS["unicode"]()
the same as charsets.UnicodeCharSet
?
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.
An instance of that, yes. Another change in this PR is that we use instances of that class instead of the class itself.
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.
Another change in this PR is that we use instances of that class instead of the class itself.
Could this change have any downsides or raise potential unexpected issues, e.g. when passing it along to the representation resolver?
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.
nope. everything is static methods.
Currently, the
qml.circuit_drawer.CircuitDrawer
class has a keywordcharset
that accepts a special classCharSet
. Higher-level functions acceptcharset
as a string, either"unicode"
or"ascii"
.graph.draw()
has to import theCHARSETS
dictionary and convert between a string and aCharSet
instance.Since the
CharSet
class is an internal implementation detail, I'd like to remove it from API to create a circuit drawer. After this PR. creating a circuit drawer class is simpler, because you can just pass it the relevant string, and the class handles the rest.This change simply moves relevant circuit drawing code into the circuit drawing classes.