Skip to content

Returning PyArray from struct #392

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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