I've been experimenting with using PyO3 to interface Rust and Python. I've run into a road block creating PyArrays from ndarrays, because I can't understand the compiler error.
error[E0308]: mismatched types
--> src/lib.rs:109:45
|
109 | PyArray::from_owned_array_bound(py, arr).unbind()
| ------------------------------- ^^^ expected `ArrayBase<OwnedRepr<_>, _>`, found `ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>`
| |
| arguments to this function are incorrect
|
= note: `ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>` and `ArrayBase<OwnedRepr<_>, _>` have similar names, but are actually distinct types
These look consistent to me, so can anyone tell me what I'm missing?
I think actually it does indicate that later in the stack trace, I just didn't have the experience to recognise the significance of what it was telling me:
|
109 | PyArray::from_owned_array_bound(py, arr).unbind()
| ------------------------------- ^^^ expected `ArrayBase<OwnedRepr<_>, _>`, found `ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>`
| |
| arguments to this function are incorrect
|
= note: `ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>` and `ArrayBase<OwnedRepr<_>, _>` have similar names, but are actually distinct types
note: `ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>` is defined in crate `ndarray`
--> /home/[user]/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ndarray-0.16.1/src/lib.rs:1280:1
|
1280 | pub struct ArrayBase<S, D>
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
note: `ArrayBase<OwnedRepr<_>, _>` is defined in crate `ndarray`
--> /home/[user]/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ndarray-0.15.6/src/lib.rs:1268:1
|
1268 | pub struct ArrayBase<S, D>
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: perhaps two different versions of crate `ndarray` are being used?