Skip to content

Commit

Permalink
Revert "Restrict visibility of some functions and structs"
Browse files Browse the repository at this point in the history
The visibility changes are really unrelated to this PR. I'll revert them.
Maybe do them in a separate PR

This reverts commit 1f8456a.
  • Loading branch information
jlapeyre committed Mar 5, 2024
1 parent 1f8456a commit caa2440
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 29 deletions.
38 changes: 19 additions & 19 deletions crates/accelerate/src/euler_one_qubit_decomposer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ use numpy::PyReadonlyArray2;

use crate::utils::SliceOrInt;

pub(super) const DEFAULT_ATOL: f64 = 1e-12;
pub const DEFAULT_ATOL: f64 = 1e-12;

#[pyclass(module = "qiskit._accelerate.euler_one_qubit_decomposer")]
pub(super) struct OneQubitGateErrorMap {
pub struct OneQubitGateErrorMap {
error_map: Vec<HashMap<String, f64>>,
}

Expand Down Expand Up @@ -60,10 +60,10 @@ impl OneQubitGateErrorMap {
}

#[pyclass(sequence)]
pub(super) struct OneQubitGateSequence {
pub(super) gates: Vec<(String, Vec<f64>)>,
pub struct OneQubitGateSequence {
pub gates: Vec<(String, Vec<f64>)>,
#[pyo3(get)]
pub(super) global_phase: f64,
pub global_phase: f64,
}

#[pymethods]
Expand Down Expand Up @@ -402,7 +402,7 @@ fn circuit_rr(
}

#[pyfunction]
pub(super) fn generate_circuit(
pub fn generate_circuit(
target_basis: &str,
theta: f64,
phi: f64,
Expand Down Expand Up @@ -553,7 +553,7 @@ pub(super) fn generate_circuit(
}

#[inline]
pub(super) fn angles_from_unitary(unitary: ArrayView2<Complex64>, target_basis: &str) -> [f64; 4] {
pub fn angles_from_unitary(unitary: ArrayView2<Complex64>, target_basis: &str) -> [f64; 4] {
match target_basis {
"U321" => params_u3_inner(unitary),
"U3" => params_u3_inner(unitary),
Expand Down Expand Up @@ -611,7 +611,7 @@ fn compute_error(

#[inline]
#[pyfunction]
fn compute_error_one_qubit_sequence(
pub fn compute_error_one_qubit_sequence(
circuit: &OneQubitGateSequence,
qubit: usize,
error_map: Option<&OneQubitGateErrorMap>,
Expand All @@ -621,7 +621,7 @@ fn compute_error_one_qubit_sequence(

#[inline]
#[pyfunction]
fn compute_error_list(
pub fn compute_error_list(
circuit: Vec<(String, Vec<f64>)>,
qubit: usize,
error_map: Option<&OneQubitGateErrorMap>,
Expand All @@ -631,7 +631,7 @@ fn compute_error_list(

#[pyfunction]
#[pyo3(signature = (unitary, target_basis_list, qubit, error_map=None, simplify=true, atol=None))]
pub(super) fn unitary_to_gate_sequence(
pub fn unitary_to_gate_sequence(
unitary: PyReadonlyArray2<Complex64>,
target_basis_list: Vec<&str>,
qubit: usize,
Expand Down Expand Up @@ -661,7 +661,7 @@ pub(super) fn unitary_to_gate_sequence(
}

#[inline]
pub(super) fn unitary_to_gate_sequence_inner(
pub fn unitary_to_gate_sequence_inner(
unitary_mat: ArrayView2<Complex64>,
target_basis_list: &[&str],
qubit: usize,
Expand All @@ -683,7 +683,7 @@ pub(super) fn unitary_to_gate_sequence_inner(
}

#[inline]
pub(super) fn det_one_qubit(mat: ArrayView2<Complex64>) -> Complex64 {
pub fn det_one_qubit(mat: ArrayView2<Complex64>) -> Complex64 {
mat[[0, 0]] * mat[[1, 1]] - mat[[0, 1]] * mat[[1, 0]]
}

Expand Down Expand Up @@ -719,7 +719,7 @@ fn params_zxz_inner(mat: ArrayView2<Complex64>) -> [f64; 4] {

#[inline]
#[pyfunction]
pub(super) fn params_zyz(unitary: PyReadonlyArray2<Complex64>) -> [f64; 4] {
pub fn params_zyz(unitary: PyReadonlyArray2<Complex64>) -> [f64; 4] {
let mat = unitary.as_array();
params_zyz_inner(mat)
}
Expand All @@ -735,7 +735,7 @@ fn params_u3_inner(mat: ArrayView2<Complex64>) -> [f64; 4] {

#[inline]
#[pyfunction]
pub(super) fn params_u3(unitary: PyReadonlyArray2<Complex64>) -> [f64; 4] {
pub fn params_u3(unitary: PyReadonlyArray2<Complex64>) -> [f64; 4] {
let mat = unitary.as_array();
params_u3_inner(mat)
}
Expand All @@ -750,7 +750,7 @@ fn params_u1x_inner(mat: ArrayView2<Complex64>) -> [f64; 4] {

#[inline]
#[pyfunction]
pub(super) fn params_u1x(unitary: PyReadonlyArray2<Complex64>) -> [f64; 4] {
pub fn params_u1x(unitary: PyReadonlyArray2<Complex64>) -> [f64; 4] {
let mat = unitary.as_array();
params_u1x_inner(mat)
}
Expand Down Expand Up @@ -778,7 +778,7 @@ fn params_xyx_inner(mat: ArrayView2<Complex64>) -> [f64; 4] {
}

#[pyfunction]
pub(super) fn params_xyx(unitary: PyReadonlyArray2<Complex64>) -> [f64; 4] {
pub fn params_xyx(unitary: PyReadonlyArray2<Complex64>) -> [f64; 4] {
let mat = unitary.as_array();
params_xyx_inner(mat)
}
Expand All @@ -802,19 +802,19 @@ fn params_xzx_inner(umat: ArrayView2<Complex64>) -> [f64; 4] {
}

#[pyfunction]
pub(super) fn params_xzx(unitary: PyReadonlyArray2<Complex64>) -> [f64; 4] {
pub fn params_xzx(unitary: PyReadonlyArray2<Complex64>) -> [f64; 4] {
let umat = unitary.as_array();
params_xzx_inner(umat)
}

#[pyfunction]
pub(super) fn params_zxz(unitary: PyReadonlyArray2<Complex64>) -> [f64; 4] {
pub fn params_zxz(unitary: PyReadonlyArray2<Complex64>) -> [f64; 4] {
let mat = unitary.as_array();
params_zxz_inner(mat)
}

#[pymodule]
pub(super) fn euler_one_qubit_decomposer(_py: Python, m: &PyModule) -> PyResult<()> {
pub fn euler_one_qubit_decomposer(_py: Python, m: &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
12 changes: 6 additions & 6 deletions crates/accelerate/src/two_qubit_decompose.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ fn transform_from_magic_basis_faer(u: Mat<c64>, reverse: bool) -> Mat<c64> {
// c64. So we implement them here. These things should be contribute
// upstream.

trait PowF {
pub trait PowF {
fn powf(self, pow: f64) -> c64;
}

Expand All @@ -147,7 +147,7 @@ impl PowF for c64 {
}
}

trait Arg {
pub trait Arg {
fn arg(self) -> f64;
}

Expand Down Expand Up @@ -232,7 +232,7 @@ fn __weyl_coordinates(unitary: MatRef<c64>) -> [f64; 3] {

#[pyfunction]
#[pyo3(text_signature = "(basis_b, basis_fidelity, unitary, /")]
fn _num_basis_gates(
pub fn _num_basis_gates(
basis_b: f64,
basis_fidelity: f64,
unitary: PyReadonlyArray2<Complex<f64>>,
Expand Down Expand Up @@ -338,7 +338,7 @@ enum Specializations {
#[derive(Clone)]
#[allow(non_snake_case)]
#[pyclass(module = "qiskit._accelerate.two_qubit_decompose", subclass)]
struct TwoQubitWeylDecomposition {
pub struct TwoQubitWeylDecomposition {
#[pyo3(get)]
a: f64,
#[pyo3(get)]
Expand Down Expand Up @@ -971,7 +971,7 @@ impl TwoQubitWeylDecomposition {
type TwoQubitSequenceVec = Vec<(String, Vec<f64>, [u8; 2])>;

#[pyclass(sequence)]
struct TwoQubitGateSequence {
pub struct TwoQubitGateSequence {
gates: TwoQubitSequenceVec,
#[pyo3(get)]
global_phase: f64,
Expand Down Expand Up @@ -1045,7 +1045,7 @@ impl TwoQubitGateSequence {
}

#[pymodule]
pub(super) fn two_qubit_decompose(_py: Python, m: &PyModule) -> PyResult<()> {
pub fn two_qubit_decompose(_py: Python, m: &PyModule) -> PyResult<()> {
m.add_wrapped(wrap_pyfunction!(_num_basis_gates))?;
m.add_class::<TwoQubitGateSequence>()?;
m.add_class::<TwoQubitWeylDecomposition>()?;
Expand Down
8 changes: 4 additions & 4 deletions crates/accelerate/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub enum SliceOrInt<'a> {
/// Return indices that sort partially ordered data.
/// If `data` contains two elements that are incomparable,
/// an error will be thrown.
pub(super) fn arg_sort<T: PartialOrd>(data: &[T]) -> Vec<usize> {
pub fn arg_sort<T: PartialOrd>(data: &[T]) -> Vec<usize> {
let mut indices = (0..data.len()).collect::<Vec<_>>();
indices.sort_by(|&a, &b| data[a].partial_cmp(&data[b]).unwrap());
indices
Expand All @@ -43,7 +43,7 @@ pub(super) fn arg_sort<T: PartialOrd>(data: &[T]) -> Vec<usize> {
/// with `dtype(complex128)`.
#[pyfunction]
#[pyo3(text_signature = "(unitary, /")]
pub(super) fn eigenvalues(py: Python, unitary: PyReadonlyArray2<Complex<f64>>) -> PyObject {
pub fn eigenvalues(py: Python, unitary: PyReadonlyArray2<Complex<f64>>) -> PyObject {
unitary
.as_array()
.into_faer_complex()
Expand All @@ -59,7 +59,7 @@ pub(super) fn eigenvalues(py: Python, unitary: PyReadonlyArray2<Complex<f64>>) -
/// with `dtype(complex128)`.
#[pyfunction]
#[pyo3(text_signature = "(unitary, /")]
pub(super) fn eigh(py: Python, unitary: PyReadonlyArray2<f64>) -> PyObject {
pub fn eigh(py: Python, unitary: PyReadonlyArray2<f64>) -> PyObject {
unitary
.as_array()
.into_faer()
Expand All @@ -72,7 +72,7 @@ pub(super) fn eigh(py: Python, unitary: PyReadonlyArray2<f64>) -> PyObject {
}

#[pymodule]
pub(super) fn utils(_py: Python, m: &PyModule) -> PyResult<()> {
pub fn utils(_py: Python, m: &PyModule) -> PyResult<()> {
m.add_wrapped(wrap_pyfunction!(eigenvalues))?;
m.add_wrapped(wrap_pyfunction!(eigh))?;
Ok(())
Expand Down

0 comments on commit caa2440

Please sign in to comment.