-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make numeric casts of ParameterExpression flexible (#6802)
Previously, ParameterExpression would refuse numeric conversions if it contained unbound parameters, even if the underlying symbolic expression had a known, fixed value. This patch passes the entire responsibility for determining if a numeric conversion is possible to Sympy/Symengine, meaning that expressions such as >>> x = Parameter('x') >>> float(x - x + 2) 2.0 are now possible. Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
- Loading branch information
1 parent
cd7e1d5
commit 7a13cc8
Showing
4 changed files
with
49 additions
and
16 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
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
14 changes: 14 additions & 0 deletions
14
...tes/notes/more-forgiving-numeric-conversions-in-ParameterExpression-6cd7316c32c67c55.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,14 @@ | ||
features: | ||
- | | ||
:obj:`~qiskit.cicuit.ParameterExpression` now delegates its numeric | ||
conversions to the underlying symbolic library, even if there are | ||
potentially unbound parameters. This allows conversions of expressions such | ||
as :: | ||
>>> from qiskit.circuit import Parameter | ||
>>> x = Parameter('x') | ||
>>> float(x - x + 2.3) | ||
2.3 | ||
where the underlying expression has a fixed value, but the parameter ``x`` | ||
is not yet bound. |
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