PyO3/rust-numpy

Returning PyArray from struct

realiti4 opened this issue · 0 comments

Hi,

I'm having a little bit of an issue when I try to use structs. I want to return an array to python, but without a luck. I tried many things, read docs, search online but coudn't find. I'd appreciate if you could point out what I am doing wrong. I am new to Rust and rust-numpy.

Here is an example code:

#[pyclass]
pub struct Process {
    data: Array1<f64>
}

#[pymethods]
impl Process {
    #[new]
    fn new(value: PyReadonlyArray1<f64>) -> Self {
        let array = value.as_array().to_owned();

        Process { 
            data: array
        }
    }

    fn my_array(&self) -> PyArray1<f64> {
        // return array
    }
}