forked from Qiskit/qiskit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add sign() method to ParameterExpression
This method allows applying the sign operation to an expression with possibly unassigned parameters.
- Loading branch information
Showing
3 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
releasenotes/notes/added-sign-feature-parameterexpression-57693dd69103dc8c.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--- | ||
features: | ||
- | | ||
Added support for expressing the sign of a :class: 'ParameterExpression' | ||
Instead of assigning a concrete value and using ''numpy.sign'' or other library functions, the user can use the instance of the ParameterExpression | ||
class to calculate the sign and can work with the sign before the expression is fully assigned. | ||
It can be used as follows:: | ||
from qiskit.circuit import Parameter | ||
b = Parameter("phi") | ||
sign_value = b.sign() | ||
print("sign of an unassigned Parameter is: ", sign_value) | ||
print("Sign of a Parameter assigned to -3 is: ", sign_value.assign(b,-3)) | ||
Refer to ' #10360<https://github.com/Qiskit/qiskit-terra/issues/10360>'__ for more details. | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters