-
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
[unitaryhack] Remove qml.utils.expand and replace with qml.operation.expand_matrix. #2654
[unitaryhack] Remove qml.utils.expand and replace with qml.operation.expand_matrix. #2654
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2654 +/- ##
==========================================
- Coverage 99.61% 99.61% -0.01%
==========================================
Files 251 251
Lines 20682 20662 -20
==========================================
- Hits 20602 20582 -20
Misses 80 80
Continue to review full report at Codecov.
|
thanks @mmore21 for this contribution! Is it ready for review? |
Hi @josh146 and @antalszava, should be ready for review. Thanks! |
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.
Hi @mmore21, this is looking great, thank you for the contribution! 🙂
One thing before approval would be to extend the functionality such that qml.utils.expand
is still valid, though it resolves to qml.operation.expand_matrix
. Although this PR addresses all usages of qml.utils.expand
, it may be that users would have their codes breaking if we made the removal in one step.
Adding the following code to the beginning of the code section of pennylane/utils.py
should help:
import warnings
def __getattr__(name):
# for more information on overwriting `__getattr__`, see https://peps.python.org/pep-0562/
if name == "expand":
warning_string = f"qml.utils.expand is deprecated; using qml.operation.expand_matrix instead."
warnings.warn(warning_string, UserWarning)
return qml.operation.expand_matrix
try:
return globals()[name]
except KeyError as e:
raise AttributeError from e
It would also be good to include a test case for this, just to make sure that a warning is raised.
Apart from this, the rest of the changes are looking great. 👍
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 @mmore21! 🎉 Thank you so much for the contribution! 😊 Very neat 👏
Thanks @antalszava, happy to make my first contribution! |
Hi @mmore21 great to have you contribute 🙂 As you've made your contribution during Unitary HACK you are eligible for swag. 🙂 To claim it you should be signed up for UnitaryHACK here and add [unitaryhack] in the title of the PR. Let me know if you have further questions (cc @CatalinaAlbornoz). |
Awesome, just registered and updated the title. Thanks for letting me know @antalszava! |
Overriding the checks: coverage decrease is due to deleted lines, docs build is lagging due to concurrency issues. |
Context:
Removes the utility function
qml.utils.expand
and replaces all references to it withqml.operation.expand_matrix
.Description of the Change:
qml.utils.expand
and its corresponding tests.qml.utils.expand
withqml.operation.expand_matrix
.test_utils.py
to better reflect the remaining test cases.Benefits:
Removes the utility function
qml.utils.expand
which is no longer used anywhere as of #2609.Possible Drawbacks:
Removes
qml.utils.expand
tests fromtest_utils.py
.Related GitHub Issues:
Closes #2637