Skip to content

Commit

Permalink
Run cargo fmt and black post rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
mtreinish committed Jul 23, 2024
1 parent 14854d0 commit 4dbe881
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 8 deletions.
4 changes: 3 additions & 1 deletion crates/accelerate/src/convert_2q_block_matrix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,9 @@ pub fn change_basis(matrix: ArrayView2<Complex64>) -> Array2<Complex64> {

#[pyfunction]
pub fn collect_2q_blocks_filter(node: &Bound<PyAny>) -> Option<bool> {
let Ok(node) = node.downcast::<DAGOpNode>() else { return None };
let Ok(node) = node.downcast::<DAGOpNode>() else {
return None;
};
let node = node.borrow();
match node.instruction.op() {
gate @ (OperationRef::Standard(_) | OperationRef::Gate(_)) => Some(
Expand Down
4 changes: 3 additions & 1 deletion crates/accelerate/src/euler_one_qubit_decomposer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1045,7 +1045,9 @@ fn matmul_1q(operator: &mut [[Complex64; 2]; 2], other: Array2<Complex64>) {

#[pyfunction]
pub fn collect_1q_runs_filter(node: &Bound<PyAny>) -> bool {
let Ok(node) = node.downcast::<DAGOpNode>() else { return false };
let Ok(node) = node.downcast::<DAGOpNode>() else {
return false;
};
let node = node.borrow();
let op = node.instruction.op();
op.num_qubits() == 1
Expand Down
13 changes: 10 additions & 3 deletions crates/circuit/src/circuit_instruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,9 @@ impl CircuitInstruction {
if other.is_instance_of::<PyTuple>() {
return Ok(Some(self_._legacy_format(py)?.eq(other)?));
}
let Ok(other) = other.downcast::<CircuitInstruction>() else { return Ok(None) };
let Ok(other) = other.downcast::<CircuitInstruction>() else {
return Ok(None);
};
let other = other.try_borrow()?;

Ok(Some(
Expand Down Expand Up @@ -508,7 +510,10 @@ impl<'py> FromPyObject<'py> for OperationFromPython {
let Some(standard) = ob_type
.getattr(intern!(py, "_standard_gate"))
.and_then(|standard| standard.extract::<StandardGate>())
.ok() else { break 'standard };
.ok()
else {
break 'standard;
};

// If the instruction is a controlled gate with a not-all-ones control state, it doesn't
// fit our definition of standard. We abuse the fact that we know our standard-gate
Expand Down Expand Up @@ -581,7 +586,9 @@ impl<'py> FromPyObject<'py> for OperationFromPython {

/// Convert a sequence-like Python object to a tuple.
fn as_tuple<'py>(py: Python<'py>, seq: Option<Bound<'py, PyAny>>) -> PyResult<Bound<'py, PyTuple>> {
let Some(seq) = seq else { return Ok(PyTuple::empty_bound(py)) };
let Some(seq) = seq else {
return Ok(PyTuple::empty_bound(py));
};
if seq.is_instance_of::<PyTuple>() {
Ok(seq.downcast_into_exact::<PyTuple>()?)
} else if seq.is_instance_of::<PyList>() {
Expand Down
4 changes: 3 additions & 1 deletion crates/circuit/src/operations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,9 @@ impl StandardGate {

pub fn __eq__(&self, other: &Bound<PyAny>) -> Py<PyAny> {
let py = other.py();
let Ok(other) = other.extract::<Self>() else { return py.NotImplemented() };
let Ok(other) = other.extract::<Self>() else {
return py.NotImplemented();
};
(*self == other).into_py(py)
}

Expand Down
4 changes: 3 additions & 1 deletion crates/circuit/src/packed_instruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,9 @@ impl Drop for PackedOperation {
fn drop_pointer_as<T>(slf: &mut PackedOperation) {
// This should only ever be called when the pointer is valid, but this is defensive just
// to 100% ensure that our `Drop` implementation doesn't panic.
let Some(pointer) = slf.try_pointer() else { return };
let Some(pointer) = slf.try_pointer() else {
return;
};
// SAFETY: `PackedOperation` asserts ownership over its contents, and the contained
// pointer can only be null if we were already dropped. We set our discriminant to mark
// ourselves as plain old data immediately just as a defensive measure.
Expand Down
4 changes: 3 additions & 1 deletion qiskit/synthesis/two_qubit/two_qubit_decompose.py
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,9 @@ def __call__(
if gate is None:
dag.apply_operation_back(self.gate, tuple(q[x] for x in qubits), check=False)
else:
op = CircuitInstruction.from_standard(gate, qubits=tuple(q[x] for x in qubits), params=params)
op = CircuitInstruction.from_standard(
gate, qubits=tuple(q[x] for x in qubits), params=params
)
node = DAGOpNode.from_instruction(op, dag=dag)
dag._apply_op_node_back(node)
return dag
Expand Down

0 comments on commit 4dbe881

Please sign in to comment.