Skip to content

Commit

Permalink
Pt2.
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinhartman committed Apr 2, 2024
1 parent ca1ad54 commit 3cdc1c5
Show file tree
Hide file tree
Showing 12 changed files with 66 additions and 86 deletions.
2 changes: 1 addition & 1 deletion crates/accelerate/src/convert_2q_block_matrix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ pub fn change_basis(matrix: ArrayView2<Complex64>) -> Array2<Complex64> {
}

#[pymodule]
pub fn convert_2q_block_matrix(_py: Python, m: &PyModule) -> PyResult<()> {
pub fn convert_2q_block_matrix(m: &Bound<PyModule>) -> PyResult<()> {
m.add_wrapped(wrap_pyfunction!(blocks_to_matrix))?;
Ok(())
}
2 changes: 1 addition & 1 deletion crates/accelerate/src/dense_layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ pub fn best_subset(
}

#[pymodule]
pub fn dense_layout(_py: Python, m: &PyModule) -> PyResult<()> {
pub fn dense_layout(m: &Bound<PyModule>) -> PyResult<()> {
m.add_wrapped(wrap_pyfunction!(best_subset))?;
Ok(())
}
2 changes: 1 addition & 1 deletion crates/accelerate/src/error_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ impl ErrorMap {
}

#[pymodule]
pub fn error_map(_py: Python, m: &PyModule) -> PyResult<()> {
pub fn error_map(m: &Bound<PyModule>) -> PyResult<()> {
m.add_class::<ErrorMap>()?;
Ok(())
}
8 changes: 6 additions & 2 deletions crates/accelerate/src/euler_one_qubit_decomposer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,11 @@ impl EulerBasis {
#[pymethods]
impl EulerBasis {
fn __reduce__(&self, py: Python) -> Py<PyAny> {
(py.get_type::<Self>(), (PyString::new(py, self.as_str()),)).into_py(py)
(
py.get_type_bound::<Self>(),
(PyString::new_bound(py, self.as_str()),),
)
.into_py(py)
}

#[new]
Expand Down Expand Up @@ -875,7 +879,7 @@ pub fn params_zxz(unitary: PyReadonlyArray2<Complex64>) -> [f64; 4] {
}

#[pymodule]
pub fn euler_one_qubit_decomposer(_py: Python, m: &PyModule) -> PyResult<()> {
pub fn euler_one_qubit_decomposer(m: &Bound<PyModule>) -> PyResult<()> {
m.add_wrapped(wrap_pyfunction!(params_zyz))?;
m.add_wrapped(wrap_pyfunction!(params_xyx))?;
m.add_wrapped(wrap_pyfunction!(params_xzx))?;
Expand Down
1 change: 0 additions & 1 deletion crates/accelerate/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ use std::env;

use pyo3::prelude::*;
use pyo3::wrap_pymodule;
use pyo3::Python;

mod convert_2q_block_matrix;
mod dense_layout;
Expand Down
4 changes: 2 additions & 2 deletions crates/accelerate/src/nlayout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ impl NLayout {
///
#[pyo3(text_signature = "(self, /)")]
fn layout_mapping(&self, py: Python<'_>) -> Py<PyList> {
PyList::new(py, self.iter_virtual()).into()
PyList::new_bound(py, self.iter_virtual()).into()
}

/// Get physical bit from virtual bit
Expand Down Expand Up @@ -217,7 +217,7 @@ impl NLayout {
}

#[pymodule]
pub fn nlayout(_py: Python, m: &PyModule) -> PyResult<()> {
pub fn nlayout(m: &Bound<PyModule>) -> PyResult<()> {
m.add_class::<NLayout>()?;
Ok(())
}
3 changes: 1 addition & 2 deletions crates/accelerate/src/optimize_1q_gates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

use pyo3::prelude::*;
use pyo3::wrap_pyfunction;
use pyo3::Python;

const PI: f64 = std::f64::consts::PI;

Expand Down Expand Up @@ -92,7 +91,7 @@ pub fn compose_u3_rust(
}

#[pymodule]
pub fn optimize_1q_gates(_py: Python, m: &PyModule) -> PyResult<()> {
pub fn optimize_1q_gates(m: &Bound<PyModule>) -> PyResult<()> {
m.add_wrapped(wrap_pyfunction!(compose_u3_rust))?;
Ok(())
}
2 changes: 1 addition & 1 deletion crates/accelerate/src/pauli_exp_val.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ pub fn density_expval_pauli_with_x(
}

#[pymodule]
pub fn pauli_expval(_py: Python, m: &PyModule) -> PyResult<()> {
pub fn pauli_expval(m: &Bound<PyModule>) -> PyResult<()> {
m.add_wrapped(wrap_pyfunction!(expval_pauli_no_x))?;
m.add_wrapped(wrap_pyfunction!(expval_pauli_with_x))?;
m.add_wrapped(wrap_pyfunction!(density_expval_pauli_with_x))?;
Expand Down
Loading

0 comments on commit 3cdc1c5

Please sign in to comment.