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
Adds a print_applied method to QNodes #378
Conversation
Codecov Report
@@ Coverage Diff @@
## master #378 +/- ##
=========================================
Coverage ? 99.58%
=========================================
Files ? 32
Lines ? 2404
Branches ? 0
=========================================
Hits ? 2394
Misses ? 10
Partials ? 0
Continue to review full report at Codecov.
|
|
||
print("\nObservables") | ||
print("===========") | ||
for op in self.ev: |
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.
Just out of curiosity, are the names of self.queue
and self.ev
changed in the new QNode? I think they are very suboptimal.
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.
They should be changed, yes; feel free to double check in #354
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.
Thanks for this neat contribution! It looks good, I have no objections.
node.print_applied() | ||
out = f.getvalue().strip() | ||
|
||
assert out == "QNode has not yet been executed." |
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.
One could think of having this in a separate test, but I think two assert statements in one test are fine.
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.
Trying to keep it contained for now, as it will need to be moved to the new QNode 😆
Context: Currently, it is hard to debug QNodes to ensure that they are executing the correct quantum circuit, for instance, if they include classical branching/logic within the QNode.
Description of the Change: Adds a
print_applied
method to QNodes, that prints the operation and observable queue as last constructed.Example:
Output:
Benefits: Easier to debug complicated QNodes.
Possible Drawbacks: Since the queue is not constructed until evaluation, using
print_applied()
will prior to first evaluation will emit a warning message and no information.Related GitHub Issues: n/a (was mentioned on the discussion forum).