smoll 0.0.2

Single MOLecule Localization.
Documentation
use crate::linalg;
use numpy::{AllowTypeChange, IntoPyArray, PyArray2, PyArrayLike1, PyArrayLike2};
use pyo3::prelude::*;
use pyo3_stub_gen::derive::*;

#[gen_stub_pyfunction(module = "smoll.linalg")]
#[pyfunction]
pub(crate) fn skew_from_rotation(
    #[gen_stub(override_type(type_repr="numpy.typing.ArrayLike", imports=("numpy.typing")))]
    r: PyArrayLike2<f64, AllowTypeChange>,
) -> PyResult<Vec<f64>> {
    Ok(linalg::skew_from_rotation(r.as_array())?)
}

#[gen_stub_pyfunction(module = "smoll.linalg")]
#[pyfunction]
pub(crate) fn rotation_from_skew<'py>(
    py: Python<'py>,
    #[gen_stub(override_type(type_repr="numpy.typing.ArrayLike", imports=("numpy.typing")))]
    a: PyArrayLike1<f64, AllowTypeChange>,
) -> PyResult<Bound<'py, PyArray2<f64>>> {
    let a = a.as_array();
    if let Some(a) = a.as_slice() {
        Ok(linalg::rotation_from_skew(a)?.into_pyarray(py))
    } else {
        let a = a.to_vec();
        Ok(linalg::rotation_from_skew(&a)?.into_pyarray(py))
    }
}