Skip to content
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

Raise a deprecation warning if Operator.decomposition is a staticmethod #2214

Merged
merged 7 commits into from
Feb 22, 2022

Conversation

josh146
Copy link
Member

@josh146 josh146 commented Feb 18, 2022

Context: As part of the recent operator refactor, the static method Operator.decomposition was renamed to Operator.compute_decomposition. The new Operator.decomposition is now an instance method.

Description of the Change: Adds a deprecation warning to alert developers to this change.

Benefits: As above.

Possible Drawbacks: n/a

Related GitHub Issues: Closes #2210

@josh146 josh146 added the bug 🐛 Something isn't working label Feb 18, 2022
@github-actions
Copy link
Contributor

Hello. You may have forgotten to update the changelog!
Please edit doc/releases/changelog-dev.md with:

  • A one-to-two sentence description of the change. You may include a small working example for new features.
  • A link back to this PR.
  • Your name (or GitHub username) in the contributors section.

@codecov
Copy link

codecov bot commented Feb 18, 2022

Codecov Report

Merging #2214 (a09256f) into master (229432d) will increase coverage by 2.74%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2214      +/-   ##
==========================================
+ Coverage   96.52%   99.26%   +2.74%     
==========================================
  Files         231      231              
  Lines       18191    18197       +6     
==========================================
+ Hits        17558    18063     +505     
+ Misses        633      134     -499     
Impacted Files Coverage Δ
pennylane/gradients/gradient_transform.py 100.00% <ø> (ø)
pennylane/operation.py 95.95% <100.00%> (+0.03%) ⬆️
pennylane/_qubit_device.py 98.72% <0.00%> (+0.31%) ⬆️
pennylane/interfaces/batch/tensorflow_autograph.py 100.00% <0.00%> (+1.17%) ⬆️
pennylane/interfaces/batch/tensorflow.py 100.00% <0.00%> (+2.04%) ⬆️
pennylane/devices/default_qubit_tf.py 90.16% <0.00%> (+3.27%) ⬆️
pennylane/interfaces/batch/torch.py 100.00% <0.00%> (+3.27%) ⬆️
pennylane/collections/qnode_collection.py 100.00% <0.00%> (+3.50%) ⬆️
pennylane/interfaces/torch.py 100.00% <0.00%> (+4.39%) ⬆️
pennylane/qnode_old.py 95.52% <0.00%> (+4.47%) ⬆️
... and 15 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 229432d...a09256f. Read the comment docs.

"Either define the static method 'compute_decomposition' instead, or use "
"'self.wires' and 'self.parameters'.",
UserWarning,
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

Copy link
Contributor

@mariaschuld mariaschuld left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll just wait for the tests to pass before approving!

@josh146
Copy link
Member Author

josh146 commented Feb 22, 2022

Thanks @mariaschuld! This requires the fix in #2218 for the tests to pass :)

@mariaschuld
Copy link
Contributor

True, but I also meant the code coverage...good to test the fix?

def decomposition(*params, wires):
qml.RY(params[0], wires=wires[0])
qml.PauliZ(wires=wires[0])
qml.RX(params[1], wires=wires[0])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we just need another case with no params here...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh oops, I didn't even spot this

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done!

Copy link
Contributor

@mariaschuld mariaschuld left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approval conditioned on checks passing :)

Thanks Josh!

@josh146 josh146 merged commit ca0c079 into master Feb 22, 2022
@josh146 josh146 deleted the warning-decomposition branch February 22, 2022 11:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Help device plugin developers deal with the Operation refactor
2 participants