-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Fix pulse parameter formatter bug with symengine #7265
Fix pulse parameter formatter bug with symengine #7265
Conversation
Pull Request Test Coverage Report for Build 1473088604
💛 - Coveralls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, makes sense that since we now have a native __complex__
for ParameterExpression
s that we should just leverage that directly. One question inline, but otherwise lgtm.
return evaluated | ||
except ValueError: | ||
except TypeError: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do both symengine and sympy raise a type error here? I assume so since the unit tests pass, but just want to confirm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
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.