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

Support powering Parameters #8959

Closed
kevinsung opened this issue Oct 19, 2022 · 0 comments · Fixed by #11235
Closed

Support powering Parameters #8959

kevinsung opened this issue Oct 19, 2022 · 0 comments · Fixed by #11235
Labels
good first issue Good for newcomers type: feature request New feature or request

Comments

@kevinsung
Copy link
Contributor

kevinsung commented Oct 19, 2022

What should we add?

At least integer powers should be supported. Floats can probably be supported too. Maybe even complex.

from qiskit.circuit import Parameter

p = Parameter("x")

print(p * p)
print(p**2)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-15-7ebbd444bd39> in <module>
      4 
      5 print(p * p)
----> 6 print(p**2)

TypeError: unsupported operand type(s) for ** or pow(): 'Parameter' and 'int'
@kevinsung kevinsung added the type: feature request New feature or request label Oct 19, 2022
@kevinsung kevinsung added the good first issue Good for newcomers label Nov 10, 2023
@github-project-automation github-project-automation bot moved this to Tagged but unassigned in Contributor Monitoring Nov 10, 2023
grossardt added a commit to grossardt/qiskit that referenced this issue Nov 12, 2023
Adds powering for qiskit.circuit.ParameterExpression allowing to use a**n, n**a, a**b, pow(a,b) etc. for ParameterExpressions a, b and numbers n. Minimal change using default support of pow by Sympy/Symengine.
Added pow to list of operators in TestParameterExpressions test case for unit testing.
fixes Qiskit#8959
Changelog: New Feature
github-merge-queue bot pushed a commit that referenced this issue Nov 29, 2023
* Add pow for Parameter

Adds powering for qiskit.circuit.ParameterExpression allowing to use a**n, n**a, a**b, pow(a,b) etc. for ParameterExpressions a, b and numbers n. Minimal change using default support of pow by Sympy/Symengine.
Added pow to list of operators in TestParameterExpressions test case for unit testing.
fixes #8959
Changelog: New Feature

* Update test_parameters.py
@github-project-automation github-project-automation bot moved this from Tagged but unassigned to Done in Contributor Monitoring Nov 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers type: feature request New feature or request
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant