Skip to content

Commit

Permalink
commiting suggested changes with updated email to clear CLA issues
Browse files Browse the repository at this point in the history
  • Loading branch information
SamD-1998 committed Sep 1, 2023
1 parent 651912b commit 981c470
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
---
features:
- |
Introduced a new feature that adds support for calculating the sign of the Parameter of the value of an expression of a Parameter class.
Instead of using numpy or other libraries, the user can use the instance of the ParameterExpression class to calculate the sign.
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
from qiskit.circuit import Parameter
b = Parameter("phi")
sign_value = b.sign()
print("sign of Parameter is: ", sign_value)
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.
Refer to ' #10360<https://github.com/Qiskit/qiskit-terra/issues/10360>'__ for more details.
2 changes: 2 additions & 0 deletions test/python/circuit/test_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -945,6 +945,8 @@ def test_sign_of_parameter(self):
b = Parameter("phi")
sign_of_parameter = b.sign()
self.assertEqual(sign_of_parameter.assign(b, -3), -1)
self.assertEqual(sign_of_parameter.assign(b, 2), 1)
self.assertEqual(sign_of_parameter.assign(b, 0), 0)

@combine(target_type=["gate", "instruction"], parameter_type=["numbers", "parameters"])
def test_decompose_propagates_bound_parameters(self, target_type, parameter_type):
Expand Down

0 comments on commit 981c470

Please sign in to comment.