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

Use isinstance(op, qml.Op) instead of operation.name string comparison in Python interfaces #691

Merged
merged 7 commits into from
Apr 22, 2024

Conversation

vincentmr
Copy link
Contributor

@vincentmr vincentmr commented Apr 19, 2024

Before submitting

Please complete the following checklist when submitting a PR:

  • All new features must include a unit test.
    If you've fixed a bug or added code that should be tested, add a test to the
    tests directory!

  • All new functions and code must be clearly commented and documented.
    If you do make documentation changes, make sure that the docs build and
    render correctly by running make docs.

  • Ensure that the test suite passes, by running make test.

  • Add a new entry to the .github/CHANGELOG.md file, summarizing the
    change, and including a link back to the PR.

  • Ensure that code is properly formatted by running make format.

When all the above are checked, delete everything above the dashed
line and fill in the pull request template.


Context:
There are several places in Python interfaces that we use string comparison for comparing PL operations and observables.
String comparison is usually considered a bad practice in compare with using isinstance(object, class_type) in Python.

Description of the Change:
Use isinstance where possible.

Benefits:

Possible Drawbacks:

Related GitHub Issues:
[sc-58642]

Copy link

codecov bot commented Apr 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.67%. Comparing base (7ff0b52) to head (7970a4a).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #691      +/-   ##
==========================================
- Coverage   98.67%   98.67%   -0.01%     
==========================================
  Files         174      174              
  Lines       22625    22624       -1     
==========================================
- Hits        22326    22325       -1     
  Misses        299      299              

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

@vincentmr vincentmr marked this pull request as ready for review April 19, 2024 19:44
@vincentmr vincentmr requested review from doctorperceptron and a team and removed request for doctorperceptron April 19, 2024 19:44
@vincentmr vincentmr added the ci:build_wheels Activate wheel building. label Apr 19, 2024
@vincentmr vincentmr requested a review from a team April 22, 2024 13:04
Copy link
Contributor

@AmintorDusko AmintorDusko left a comment

Choose a reason for hiding this comment

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

I think it looks good so far.
Do you have any idea why some CIs are failing?

@vincentmr
Copy link
Contributor Author

I think it looks good so far. Do you have any idea why some CIs are failing?

I think it is just the usual: some wheel building failing and needs restart, codecov prematurely reporting before all Linux tests are over. I'll monitor.

Copy link
Contributor

@AmintorDusko AmintorDusko left a comment

Choose a reason for hiding this comment

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

Well, in terms of coding and general testing, your PR looks pretty good.
I will approve now, let me know if you need any help with the falling CIs.

@vincentmr vincentmr merged commit 4bbee4d into master Apr 22, 2024
83 checks passed
@vincentmr vincentmr deleted the feature/isinstance branch April 22, 2024 18:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci:build_wheels Activate wheel building.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants