From de8e4dd83627a63fb00f3c8f65bd1dd8bb7e2eac Mon Sep 17 00:00:00 2001 From: nick bronn Date: Tue, 25 Oct 2022 15:10:58 -0400 Subject: [PATCH] Cast ParameterExpression to float in RZXBuilder and RZXCalibrationBuilderNoEcho (#8965) * committing changes but still debugging * commiting to check necessary changes * added explicit casting to get_calibration in rzx_builder.py in two places * found a linting error in alap.py * Remove redundant float cast Co-authored-by: Matthew Treinish --- qiskit/transpiler/passes/calibration/rzx_builder.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/qiskit/transpiler/passes/calibration/rzx_builder.py b/qiskit/transpiler/passes/calibration/rzx_builder.py index 6c4a6e4f2efd..b17af6e4c51a 100644 --- a/qiskit/transpiler/passes/calibration/rzx_builder.py +++ b/qiskit/transpiler/passes/calibration/rzx_builder.py @@ -164,11 +164,17 @@ def get_calibration(self, node_op: CircuitInst, qubits: List) -> Union[Schedule, schedule: The calibration schedule for the RZXGate(theta). Raises: + QiskitError: if rotation angle is not assigned. QiskitError: If the control and target qubits cannot be identified. CalibrationNotAvailable: RZX schedule cannot be built for input node. """ theta = node_op.params[0] + try: + theta = float(theta) + except TypeError as ex: + raise QiskitError("Target rotation angle is not assigned.") from ex + rzx_theta = Schedule(name="rzx(%.3f)" % theta) rzx_theta.metadata["publisher"] = CalibrationPublisher.QISKIT @@ -275,12 +281,18 @@ def get_calibration(self, node_op: CircuitInst, qubits: List) -> Union[Schedule, schedule: The calibration schedule for the RZXGate(theta). Raises: + QiskitError: if rotation angle is not assigned. QiskitError: If the control and target qubits cannot be identified, or the backend does not natively support the specified direction of the cx. CalibrationNotAvailable: RZX schedule cannot be built for input node. """ theta = node_op.params[0] + try: + theta = float(theta) + except TypeError as ex: + raise QiskitError("Target rotation angle is not assigned.") from ex + rzx_theta = Schedule(name="rzx(%.3f)" % theta) rzx_theta.metadata["publisher"] = CalibrationPublisher.QISKIT