Description
How does one convert the type of an array? We're trying to go from an owned Array2<u32>
to an owned Array2<usize>
.
We've tried to_owned(), into_owned(), and from(), and can't find anything that works. Do we need to resort to iterators for this?
As a documentation feature request, could you please add the answer to the "ndarray_for_numpy_users" page?
The wider context is that we're trying to get our data out of python using the rust-numpy crate:
https://github.com/rust-numpy/rust-numpy
but their example doesn't get the data all the way into an owned ndarray; it's still a view into a custom type wrapping data that is still owned by a python interpreter.
It already took us hours to get this far:
let a = pyarray.as_array().unwrap();
let b:ArrayView2<i32> = a.into_dimensionality::<Ix2>().unwrap();
let c:ndarray::Array2<i32> = b.to_owned();
I'm hoping you can get us the rest of the way there, or maybe even point us to a conversion path that only incurs one copy rather than two...