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

create a PL-specific deprecation warning #4814

Merged
merged 4 commits into from
Nov 10, 2023
Merged

Conversation

timmysilv
Copy link
Contributor

@timmysilv timmysilv commented Nov 9, 2023

Context:
When we deprecate features, it's hard to identify that we've done it.

Description of the Change:
Replace all deprecation warning categories with the new PennyLaneDeprecationWarning

Benefits:
We can add a pytest.ini filter to make this into failures on plugins!

[pytest]
filterwarnings =
    error::pennylane.PennyLaneDeprecationWarning

(I ran a test locally with a plugin that was setting Observable.return_type and saw that it raised the error)

Possible Drawbacks:
N/A

@timmysilv timmysilv requested a review from a team November 9, 2023 21:45
Copy link
Contributor

github-actions bot commented Nov 9, 2023

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.

Copy link
Contributor

@mudit2812 mudit2812 left a comment

Choose a reason for hiding this comment

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

Thanks! I like this change

@timmysilv timmysilv requested a review from a team November 9, 2023 22:03
Copy link

codecov bot commented Nov 9, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (2c9a049) 99.64% compared to head (a273577) 99.63%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4814      +/-   ##
==========================================
- Coverage   99.64%   99.63%   -0.01%     
==========================================
  Files         381      381              
  Lines       34382    34123     -259     
==========================================
- Hits        34260    34000     -260     
- Misses        122      123       +1     
Files Coverage Δ
pennylane/__init__.py 100.00% <100.00%> (ø)
pennylane/operation.py 97.26% <ø> (-0.02%) ⬇️
pennylane/ops/functions/generator.py 100.00% <ø> (ø)
pennylane/ops/op_math/controlled.py 99.63% <ø> (ø)
pennylane/tape/qscript.py 100.00% <ø> (ø)
pennylane/transforms/__init__.py 100.00% <ø> (ø)
pennylane/transforms/batch_transform.py 96.03% <ø> (ø)
pennylane/transforms/core/transform_dispatcher.py 100.00% <ø> (ø)
pennylane/transforms/op_transforms.py 100.00% <ø> (ø)
pennylane/transforms/qfunc_transforms.py 90.74% <100.00%> (ø)
... and 1 more

... and 40 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@albi3ro albi3ro left a comment

Choose a reason for hiding this comment

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

Worth adding a changelog entry, probably under deprecations, and a comment at the top of deprecations.rst

@timmysilv timmysilv requested a review from albi3ro November 10, 2023 13:36
Copy link
Contributor

@albi3ro albi3ro left a comment

Choose a reason for hiding this comment

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

We should potentially have a follow up PR that adds the pytest.ini change to PennyLane itself, but that may take a bunch of test changes.

Hopefully this will make deprecations much cleaner 👍

@timmysilv timmysilv merged commit 52b9f5c into master Nov 10, 2023
32 checks passed
@timmysilv timmysilv deleted the pl-deprecation-warning branch November 10, 2023 14:30
@trbromley
Copy link
Contributor

How will this change affect the user?

  • Will the message they see be different?
  • Will they have to update any functionality they have for filtering out warnings?

@albi3ro
Copy link
Contributor

albi3ro commented Nov 13, 2023

Message is the exact same. Only now the type says PennyLaneDeprecationWarning instead of UserWarning. As it inherits from UserWarning, pre-existing filters will still work. It will just be easier to have finer control over filtering the warnings.

Screenshot 2023-11-13 at 1 03 06 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants