You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
In this case, it can only be fixed by pyo3. We can not implement the ToPyObject trait for arrays in this crate.
It sounds like pyo3 is simply missing a impl ToPyObject for [T; N]. At a first glance, I don't see a reason why that trait wouldn't be possible to implement for arrays. It's probably just missing because nobody thought to add it.
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 implementToPyObject
.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]
, notToPyObject
.Thus, I do not know if this is an issue with
inline_python
, or withPyO3
. Since I am directly depending oninline_python
I decided to open an issue here.Maybe related: #10
The text was updated successfully, but these errors were encountered: