Skip to content

Commit

Permalink
Remove PyResult
Browse files Browse the repository at this point in the history
  • Loading branch information
mtreinish committed May 22, 2024
1 parent 42f8585 commit 33493a0
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions crates/accelerate/src/dense_layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ use ahash::RandomState;
use hashbrown::{HashMap, HashSet};
use indexmap::IndexSet;
use ndarray::prelude::*;
use numpy::PyReadonlyArray2;
use numpy::IntoPyArray;
use numpy::PyReadonlyArray2;
use rayon::prelude::*;

use pyo3::prelude::*;
Expand Down Expand Up @@ -108,23 +108,23 @@ pub fn best_subset(
use_error: bool,
symmetric_coupling_map: bool,
error_matrix: PyReadonlyArray2<f64>,
) -> PyResult<(PyObject, PyObject, PyObject)> {
) -> (PyObject, PyObject, PyObject) {
let coupling_adj_mat = coupling_adjacency.as_array();
let err = error_matrix.as_array();
let (rows, cols, best_map) = best_subset_inner(
let [rows, cols, best_map] = best_subset_inner(
num_qubits,
coupling_adj_mat,
num_meas,
num_cx,
use_error,
symmetric_coupling_map,
err,
)?;
Ok((
rows.to_pyarray_bound(py).into(),
cols.to_pyarray_bound(py).into(),
best_map.to_pyarray_bound(py).into(),
))
);
(
rows.into_pyarray_bound(py).into(),
cols.into_pyarray_bound(py).into(),
best_map.into_pyarray_bound(py).into(),
)
}

pub fn best_subset_inner(
Expand All @@ -135,7 +135,7 @@ pub fn best_subset_inner(
use_error: bool,
symmetric_coupling_map: bool,
err: ArrayView2<f64>,
) -> PyResult<(Vec<usize>, Vec<usize>, Vec<usize>)> {
) -> [Vec<usize>; 3] {
let coupling_shape = coupling_adj_mat.shape();
let avg_meas_err = err.diag().mean().unwrap();

Expand Down Expand Up @@ -241,7 +241,7 @@ pub fn best_subset_inner(
let rows: Vec<usize> = new_cmap.iter().map(|edge| edge[0]).collect();
let cols: Vec<usize> = new_cmap.iter().map(|edge| edge[1]).collect();

Ok((rows, cols, best_map))
[rows, cols, best_map]
}

#[pymodule]
Expand Down

0 comments on commit 33493a0

Please sign in to comment.