Fix pulse parameter formatter bug with symengine#7265
Merged
mergify[bot] merged 3 commits intoNov 17, 2021
Conversation
added 2 commits
November 15, 2021 18:01
Pull Request Test Coverage Report for Build 1473088604
💛 - Coveralls |
mtreinish
reviewed
Nov 15, 2021
Member
mtreinish
left a comment
There was a problem hiding this comment.
LGTM, makes sense that since we now have a native __complex__ for ParameterExpressions that we should just leverage that directly. One question inline, but otherwise lgtm.
|
|
||
| return evaluated | ||
| except ValueError: | ||
| except TypeError: |
Member
There was a problem hiding this comment.
Do both symengine and sympy raise a type error here? I assume so since the unit tests pass, but just want to confirm
Contributor
Author
There was a problem hiding this comment.
Yes, locally I uninstalled symengine and it worked. Note that symengine and sympry don't raise errors. This is exception for
https://github.com/Qiskit/qiskit-terra/blob/277aa87f81a21d7516652051d6c615d18b291ea2/qiskit/circuit/parameterexpression.py#L442-L445
taalexander
approved these changes
Nov 16, 2021
mtreinish
approved these changes
Nov 17, 2021
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Old formatter logic assumes always evaluated complex value is input, however, with symengine a parameter expression remains unevaluated though values are assigned. This usually crashes string-based complex value evaluation.
Details and comments
Use direct typecast instead of string-based evaluation. Truncation with the default of 10 decimal point is added to eliminate truncation error during typecast.