Skip to content

Commit

Permalink
Fix: leverage new methods in layers
Browse files Browse the repository at this point in the history
- Fix incorrect re-insertion of last_node.
  • Loading branch information
raynelfss committed Aug 21, 2024
1 parent 05dcf30 commit d003414
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions crates/circuit/src/dag_circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4288,9 +4288,7 @@ def _format(operand):

let mut new_layer = self.copy_empty_like(py, vars_mode)?;

for (node, _) in op_nodes {
new_layer.push_back(py, node.clone())?;
}
new_layer.add_from_iter(py, op_nodes.iter().map(|(inst, _)| (*inst).clone()))?;

let new_layer_op_nodes = new_layer.op_nodes(false).filter_map(|node_index| {
match new_layer.dag.node_weight(node_index) {
Expand Down Expand Up @@ -6243,7 +6241,7 @@ impl DAGCircuit {
};
qubit_last_nodes
.entry(*qubit)
.and_modify(|val| *val = (new_node, qubit_last_node.1.clone()));
.or_insert((new_node, qubit_last_node.1.clone()));
nodes_to_connect.insert(qubit_last_node);
}

Expand All @@ -6264,7 +6262,7 @@ impl DAGCircuit {
};
clbit_last_nodes
.entry(clbit)
.and_modify(|val| *val = (new_node, clbit_last_node.1.clone()));
.or_insert((new_node, clbit_last_node.1.clone()));
nodes_to_connect.insert(clbit_last_node);
}

Expand Down

0 comments on commit d003414

Please sign in to comment.