use crate::filter;
use numpy::{
AllowTypeChange, IntoPyArray, PyArray1, PyArrayDyn, PyArrayLikeDyn, PyArrayMethods,
PyReadonlyArrayDyn,
};
use pyo3::PyResult;
use pyo3::prelude::*;
use pyo3_stub_gen::derive::*;
#[gen_stub_pyfunction(module = "smoll.filter")]
#[pyfunction]
pub(crate) fn fft<'py>(
py: Python<'py>,
#[gen_stub(override_type(type_repr="numpy.typing.ArrayLike", imports=("numpy.typing")))]
array: PyArrayLikeDyn<f64, AllowTypeChange>,
) -> PyResult<Bound<'py, PyArrayDyn<num::Complex<f64>>>> {
Ok(filter::fft(array.as_array())?.into_pyarray(py))
}
#[gen_stub_pyfunction(module = "smoll.filter")]
#[pyfunction]
pub(crate) fn ifft<'py>(
py: Python<'py>,
#[gen_stub(override_type(type_repr="numpy.typing.ArrayLike", imports=("numpy.typing")))]
array: PyReadonlyArrayDyn<'py, num::Complex<f64>>,
) -> PyResult<Bound<'py, PyArrayDyn<num::Complex<f64>>>> {
Ok(filter::ifft(array.readonly().as_array())?.into_pyarray(py))
}
#[gen_stub_pyfunction(module = "smoll.filter")]
#[pyfunction]
pub(crate) fn fft_freq<'py>(py: Python<'py>, size: usize) -> Bound<'py, PyArray1<f64>> {
filter::fft_freq(size).into_pyarray(py)
}
#[gen_stub_pyfunction(module = "smoll.filter")]
#[pyfunction]
pub(crate) fn fft_shift<'py>(
py: Python<'py>,
#[gen_stub(override_type(type_repr="numpy.typing.ArrayLike", imports=("numpy.typing")))]
array: PyArrayLikeDyn<f64, AllowTypeChange>,
) -> Bound<'py, PyArrayDyn<f64>> {
filter::fft_shift(array.as_array()).into_pyarray(py)
}
#[gen_stub_pyfunction(module = "smoll.filter")]
#[pyfunction]
pub(crate) fn gaussian(x: Vec<f64>, mu: f64, sigma: f64) -> Vec<f64> {
filter::gaussian(&x, mu, sigma)
}
#[gen_stub_pyfunction(module = "smoll.filter")]
#[pyfunction]
pub(crate) fn gaussian_kernel<'py>(
py: Python<'py>,
shape: Vec<usize>,
sigma: Vec<f64>,
) -> PyResult<Bound<'py, PyArrayDyn<num::Complex<f64>>>> {
Ok(filter::gaussian_kernel(&shape, &sigma)?.into_pyarray(py))
}
#[gen_stub_pyfunction(module = "smoll.filter")]
#[pyfunction]
pub(crate) fn gaussian_smooth<'py>(
py: Python<'py>,
#[gen_stub(override_type(type_repr="numpy.typing.ArrayLike", imports=("numpy.typing")))]
array: PyArrayLikeDyn<f64, AllowTypeChange>,
sigma: Vec<f64>,
) -> PyResult<Bound<'py, PyArrayDyn<f64>>> {
Ok(filter::gaussian_smooth(array.as_array(), &sigma)?.into_pyarray(py))
}