Skip to content

Commit

Permalink
Fix some clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
mtreinish committed Jul 26, 2024
1 parent bc7d989 commit c056206
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
15 changes: 8 additions & 7 deletions crates/circuit/src/dag_circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1948,6 +1948,7 @@ def _format(operand):
///
/// Raises:
/// DAGCircuitError: if ``other`` is wider or there are duplicate edge mappings.
#[allow(clippy::too_many_arguments)]
#[pyo3(signature = (other, qubits=None, clbits=None, front=false, inplace=true, *, inline_captures=false))]
fn compose(
slf: PyRefMut<Self>,
Expand Down Expand Up @@ -3075,11 +3076,9 @@ def _format(operand):
_ => return Err(DAGCircuitError::new_err("expected node")),
};

let build_wire_map = |wires: &Bound<PyList>| -> PyResult<(
HashMap<Qubit, Qubit>,
HashMap<Clbit, Clbit>,
Py<PyDict>,
)> {
type WireMapsTuple = (HashMap<Qubit, Qubit>, HashMap<Clbit, Clbit>, Py<PyDict>);

let build_wire_map = |wires: &Bound<PyList>| -> PyResult<WireMapsTuple> {
let qargs_list = BUILTIN_LIST
.get_bound(py)
.call1((bound_node.borrow().get_qargs(py),))?;
Expand Down Expand Up @@ -3590,7 +3589,7 @@ new_condition = (new_target, value)
self.decrement_op(old_packed.op.name().to_string());
self.increment_op(new_op.operation.name().to_string());

Ok(self.get_node(py, node_index)?)
self.get_node(py, node_index)
}

/// Decompose the circuit into sets of qubits with no gates connecting them.
Expand Down Expand Up @@ -5122,7 +5121,9 @@ impl DAGCircuit {
}

fn topological_nodes(&self) -> PyResult<impl Iterator<Item = NodeIndex>> {
let key = |node: NodeIndex| -> Result<(Option<&[Qubit]>, Option<&[Clbit]>), Infallible> {
type SortKeyType<'a> = (Option<&'a [Qubit]>, Option<&'a [Clbit]>);

let key = |node: NodeIndex| -> Result<SortKeyType, Infallible> {
Ok(match &self.dag[node] {
NodeType::Operation(packed) => (
Some(self.qargs_cache.intern(packed.qubits).as_slice()),
Expand Down
2 changes: 2 additions & 0 deletions crates/circuit/src/dag_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,13 @@ impl DAGNode {
}
}

#[allow(non_snake_case)]
#[getter]
fn get__node_id(&self) -> isize {
self.py_nid()
}

#[allow(non_snake_case)]
#[setter]
fn set__node_id(&mut self, nid: isize) {
self.node = match nid {
Expand Down

0 comments on commit c056206

Please sign in to comment.