Skip to content

Cannot use array ([T; N]) in python聽#51

Description

@PigeonF

Hi!

First, thanks for the awesome project, it is very useful for plotting 馃憤 .

I am trying to use an array in inline_python, but it cannot be converted, because [T; N] does not implement ToPyObject.

let array = [0.0f64; 64];
inline_python::python! {
    a = 'array
};
Error Message
error[E0277]: the trait bound `[f64; 64]: ToPyObject` is not satisfied
   --> src\main.rs:69:13
    |
68  | /     inline_python::python! {
69  | |         a = 'array
    | |             ^^^^^^ the trait `ToPyObject` is not implemented for `[f64; 64]`
70  | |     };
    | |_____- required by a bound introduced by this call

One solution is to convert the array to a slice, but I think supporting to an array should still be supported.

While searching, I found https://github.com/PyO3/pyo3/blob/main/src/conversions/array.rs, which allows for conversion between arrays and python objects, but as far as I can tell, this is not picked up because it only implements IntoPy<PyObject> for [T; N], not ToPyObject.

Thus, I do not know if this is an issue with inline_python, or with PyO3. Since I am directly depending on inline_python I decided to open an issue here.

Maybe related: #10

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions