`PyArrayLike1<'py, Complex64, TypeMustMatch>` cannot be used as function argument
Closed this issue · 1 comments
benruijl commented
I want to have a function that accepts [1+2j] and np.array([1.j], dtype=np.complex128). I tried:
fn evaluate_complex_flat<'py>(
&mut self,
py: Python<'py>,
inputs: PyArrayLike1<'py, Complex64, TypeMustMatch>,
) but I get:
error[E0277]: the trait bound `PyArrayLike<'_, num_complex::Complex<f64>, Dim<[usize; 1]>>: PyFunctionArgument<'_, '_, false>` is not satisfied
--> src/api/python.rs:12195:17
|
12195 | inputs: PyArrayLike1<'py, Complex64, TypeMustMatch>,
| ^^^^^^^^^^^^ the trait `FromPyObject<'_>` is not implemented for `PyArrayLike<'_, num_complex::Complex<f64>, Dim<[usize; 1]>>`
|
= help: the trait `FromPyObject<'_>` is implemented for `PyArrayLike<'_, T, D, C>`
= note: required for `PyArrayLike<'_, num_complex::Complex<f64>, Dim<[usize; 1]>>` to implement `FromPyObjectBound<'_, '_>`
= note: required for `PyArrayLike<'_, num_complex::Complex<f64>, Dim<[usize; 1]>>` to implement `PyFunctionArgument<'_, '_, false>`
Icxolu commented
Make sure you have enabled pyo3s "num-complex" feature. With that feature enabled this works for me.