Skip to content

Commit fcebffd

Browse files
mtreinishjakelishman
authored andcommitted
Also include standard gates in .gate_nodes() return
1 parent 7ca3ff8 commit fcebffd

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

crates/circuit/src/dag_circuit.rs

+8-7
Original file line numberDiff line numberDiff line change
@@ -3913,15 +3913,16 @@ new_condition = (new_target, value)
39133913
/// Returns:
39143914
/// list[DAGOpNode]: the list of DAGOpNodes that represent gates.
39153915
fn gate_nodes(&self, py: Python) -> PyResult<Vec<Py<PyAny>>> {
3916-
let mut nodes = Vec::new();
3917-
for (node, weight) in self.dag.node_references() {
3918-
if let NodeType::Operation(ref packed) = weight {
3919-
if let OperationRef::Gate(_) = packed.op.view() {
3920-
nodes.push(self.unpack_into(py, node, weight)?);
3916+
self.dag.node_references().filter_map(|(node, weight)| {
3917+
match weight {
3918+
NodeType::Operation(ref packed) => match packed.op.view() {
3919+
OperationRef::Gate(_) | OperationRef::Standard(_) => Some(self.unpack_into(py, node, weight)),
3920+
_ => None
39213921
}
3922+
_ => None,
39223923
}
3923-
}
3924-
Ok(nodes)
3924+
})
3925+
.collect()
39253926
}
39263927

39273928
/// Get the set of "op" nodes with the given name.

0 commit comments

Comments
 (0)