-
Notifications
You must be signed in to change notification settings - Fork 117
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
fix: Handling for autoqasm subroutine return values #633
Conversation
Codecov Report
@@ Coverage Diff @@
## feature/autoqasm #633 +/- ##
===================================================
Coverage ? 99.91%
===================================================
Files ? 147
Lines ? 8665
Branches ? 1866
===================================================
Hits ? 8658
Misses ? 4
Partials ? 3 |
|
||
if isinstance(value, oqpy.base.Var): | ||
# TODO: If name is defined in value, it might be different from target_name. |
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.
@yitchen-tim I believe this TODO is outdated now. It looks like we handle the target and value names correctly. But please let me know if I am misunderstanding.
to the conversion process. Or, the oqpy variable returned from the converted function, | ||
if this is a subroutine conversion. |
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.
Super nit, should these be hanging indent? I think we've been inconsistent about it. I guess it's not so important with a return value, cause there aren't other values to delineate from
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 think the linter enforces no hanging indent on return value docstrings - seems consistent with most of the other functions I see. (But unfortunately I don't think the linter checks docstrings on private functions...)
@@ -302,11 +308,15 @@ def _convert_program_as_subroutine( | |||
oqpy_program.set(return_variable, subroutine_function_call) | |||
elif return_instance is not None: | |||
return_variable = aq_types.wrap_value(return_instance) | |||
oqpy_program.declare(return_variable) |
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.
Does this modify return_variable?
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.
No, it only modifies the oqpy_program state.
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.
Couple questions for my understanding, and a suggestion to move the tests to test_types. Looks good!
Issue #, if available:
Description of changes:
Testing done:
Merge Checklist
Put an
x
in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your pull request.General
Tests
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.