Skip to content

Commit

Permalink
FIx: Adapt to 13033
Browse files Browse the repository at this point in the history
  • Loading branch information
raynelfss committed Aug 28, 2024
1 parent 70b4f89 commit da3b3ae
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions crates/circuit/src/dag_circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6390,13 +6390,13 @@ impl DAGCircuit {

// Take ownership of the interners.
let mut qubit_interner = if qubit_order.is_some() {
IndexedInterner::new()
Interner::new()
} else {
qc_data.qargs_interner().clone()
};

let mut clbit_interner = if clbit_order.is_some() {
IndexedInterner::new()
Interner::new()
} else {
qc_data.cargs_interner().clone()
};
Expand Down Expand Up @@ -6461,15 +6461,15 @@ impl DAGCircuit {
let instructions: Vec<PackedInstruction> = qc_data
.iter()
.cloned()
.map(|instr| -> PyResult<PackedInstruction> {
.map(|mut instr| -> PyResult<PackedInstruction> {
// Re-map the qubits
let qargs: Vec<Qubit> = qc_data.get_qargs(instr.qubits).to_vec();
if qubit_order.is_some() {
let ordered_qargs = qargs
.iter()
.map(|index| qubit_set[index.0 as usize])
.collect();
Interner::intern(&mut qubit_interner, ordered_qargs)?;
instr.qubits = qubit_interner.insert_owned(ordered_qargs);
}
// Remap the clbits
let cargs: Vec<Clbit> = qc_data.get_cargs(instr.clbits).to_vec();
Expand All @@ -6478,7 +6478,7 @@ impl DAGCircuit {
.iter()
.map(|index| clbit_set[index.0 as usize])
.collect();
Interner::intern(&mut clbit_interner, ordered_cargs)?;
instr.clbits = clbit_interner.insert_owned(ordered_cargs);
}

num_edges += qargs.len() + cargs.len();
Expand Down Expand Up @@ -6511,8 +6511,8 @@ impl DAGCircuit {
new_dag.metadata = qc.metadata.map(|meta| meta.unbind());

// Copy over all interners and registers
new_dag.qargs_cache = qubit_interner;
new_dag.cargs_cache = clbit_interner;
new_dag.qargs_interner = qubit_interner;
new_dag.cargs_interner = clbit_interner;

new_dag.qubits = qubit_data;
new_dag.clbits = clbit_data;
Expand Down

0 comments on commit da3b3ae

Please sign in to comment.