Skip to content

Returning PyArray from struct #392

@realiti4

Description

@realiti4

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
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions