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

fix Resources.__str__ to match attribute names #6581

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

Qottmann
Copy link
Contributor

Minor thing:
The resources repr and attribute names dont coincide, e.g.

>>> U = qml.TrotterProduct(qml.X(0) + qml.Y(0), time=0.5, n=2, order=2)
>>> U.resources()
wires: 1
gates: 8
depth: 8
shots: Shots(total=None)
gate_types:
{'Exp': 8}
gate_sizes:
{1: 8}

I would e.g. expect to be able to obtain the number of gates but neither U.resources().gates nor U.resources()["gates"] or getattr(U.resources(), "gates") work - because the attribute is actually called num_gates.

This PR just fixes the str representation to match the attribute name.
This is such a minor thing that it was easier and faster to just fix it than open an issue / sc story 😬

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.

Copy link

codecov bot commented Nov 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.29%. Comparing base (bf03136) to head (e5f1398).
Report is 4 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6581      +/-   ##
==========================================
- Coverage   99.30%   99.29%   -0.01%     
==========================================
  Files         454      454              
  Lines       43269    43267       -2     
==========================================
- Hits        42967    42964       -3     
- Misses        302      303       +1     

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

Copy link
Contributor

@Jaybsoni Jaybsoni left a comment

Choose a reason for hiding this comment

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

Nice catch! Although I know we have lots of docstrings and documentation where we have hand-written the output of printing a resources object. You will need to track those instances down to complete the update 😢.

Thanks for the fix!

@Qottmann
Copy link
Contributor Author

Good point, thanks @Jaybsoni . Wasnt as bad, updated it ✅

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.

2 participants