Skip to content

Commit

Permalink
Adjust QuantumError.to_dict() to handle lack of Instruction.condition
Browse files Browse the repository at this point in the history
In Qiskit 2.0 the Instruction.condition attribute will be removed
following it's deprecation in 1.3.0. This attribute has been superseded
by the IfElseOp which covers the use case but offers more functionality.
The removal is pending in Qiskit/qiskit#13506 and the use of qiskit-aer
in Qiskit's tests is blocking progress on that PR. This commit makes the
usage of .condition optional to maintain compatibility with Qiskit<2.0
but also work in >=2.0 with the attribute removed.
  • Loading branch information
mtreinish committed Jan 25, 2025
1 parent 0bd1716 commit 7035f6a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions qiskit_aer/noise/errors/quantum_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,9 @@ def to_dict(self):
inst_dict["params"] = inst.operation.params
if inst.operation.label:
inst_dict["label"] = inst.operation.label
if inst.operation.condition:
inst_dict["condition"] = inst.operation.condition
condition = getattr(inst.operation, "condition", None)
if condition:
inst_dict["condition"] = condition
circ_inst.append(inst_dict)
instructions.append(circ_inst)
# Construct error dict
Expand Down

0 comments on commit 7035f6a

Please sign in to comment.