Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert ParameterExpression to float in QasmQobjInstruction.to_dict() (…
…Qiskit#3959) In Qiskit#3383 we removed marshmallow from the qobj objects a side effect of this was the type coercion to something that was serializable with a bare json.dumps() call was removed. In the majority of cases this wasn't necessary as this was either something easily handled in a json serializer class, or for aer (and other local simulators) are native types that casting adds unnecessary overhead. However, there was one edge case missed, the ParameterExpression class which is used for parameterized circuits. This is a terra class and while it's easy to fix in the ibmq provider for json serialization (although it hasn't been yet, a PR will be pushed for this shortly) Aer doesn't have native handling of this class. As a workaround until this is fixed the QasmQobjInstruction's to_dict() method will loop over gate parameters to check if there are any ParameterExpression objects and convert them to a float. There is likely a performance penalty for doing this, and when a more longstanding fix is built we should remove this.
- Loading branch information