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 inspect module to get argument counts #1151

Merged
merged 3 commits into from
Sep 24, 2024
Merged

Use inspect module to get argument counts #1151

merged 3 commits into from
Sep 24, 2024

Conversation

dime10
Copy link
Contributor

@dime10 dime10 commented Sep 23, 2024

Using qml.cond on PennyLane operators raises an exception because the target does not have a __code__ attribute:

@qjit
@qml.qnode(qml.device("lightning.qubit", wires=1))
def f(x: int):
    qml.cond(x < 5, qml.Hadamard)(0)
    return qml.probs()
AttributeError: type object 'Hadamard' has no attribute '__code__'

[sc-74292]

@dime10 dime10 added bug Something isn't working frontend Pull requests that update the frontend labels Sep 23, 2024
@dime10 dime10 requested a review from a team September 23, 2024 23:06
Copy link

codecov bot commented Sep 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.87%. Comparing base (4524773) to head (8b36f5b).
Report is 202 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1151   +/-   ##
=======================================
  Coverage   97.87%   97.87%           
=======================================
  Files          76       76           
  Lines       10850    10851    +1     
  Branches     1283     1283           
=======================================
+ Hits        10619    10620    +1     
  Misses        179      179           
  Partials       52       52           

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

Copy link
Contributor

@joeycarter joeycarter left a comment

Choose a reason for hiding this comment

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

Looks good to me!

@dime10 dime10 merged commit f122439 into main Sep 24, 2024
42 checks passed
@dime10 dime10 deleted the bug-cond-args branch September 24, 2024 15:01
@dime10 dime10 added this to the v0.8.2 milestone Oct 9, 2024
dime10 added a commit that referenced this pull request Oct 11, 2024
Using `qml.cond` on PennyLane operators raises an exception because the
target does not have a `__code__` attribute:
```py
@qjit
@qml.qnode(qml.device("lightning.qubit", wires=1))
def f(x: int):
    qml.cond(x < 5, qml.Hadamard)(0)
    return qml.probs()
```
```
AttributeError: type object 'Hadamard' has no attribute '__code__'
```

[sc-74292]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working frontend Pull requests that update the frontend
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants