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

Parameter has no __pow__ #11226

Closed
grossardt opened this issue Nov 10, 2023 · 2 comments
Closed

Parameter has no __pow__ #11226

grossardt opened this issue Nov 10, 2023 · 2 comments
Labels
type: feature request New feature or request

Comments

@grossardt
Copy link
Contributor

What should we add?

from qiskit.circuit import Parameter
a = Parameter('a')
a**2

will raise a TypeError: unsupported operand type(s) for ** or pow(): 'Parameter' and 'int' (tested with qiskit 0.44.1, qiskit-terra 0.25.1).
On the other hand, a**2 can be easily constructed as (2 * a.log()).exp() which yields ParameterExpression(a**2)

It seems reasonable to also implement Paramater.__pow__ at least for int or float powers? Or is there a reason why this is not implemented that I am missing?

@grossardt grossardt added the type: feature request New feature or request label Nov 10, 2023
@kevinsung
Copy link
Contributor

Duplicate of #8959

@kevinsung kevinsung marked this as a duplicate of #8959 Nov 10, 2023
@grossardt
Copy link
Contributor Author

Duplicate of #8959

Dang, missed that when searching. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature request New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants