Reputation: 3243
Looking for the functionality of the .split_of
function as used with a Vec
(https://doc.rust-lang.org/std/vec/struct.Vec.html#method.split_off)
Currently I am trying to use the function split_at
: (docs: https://docs.rs/ndarray/0.13.1/ndarray/struct.ArrayBase.html#method.split_at)
Usage:
let mut data: Array2<f32> = array![[1.,2.],[3.,4.],[5.,6.],[7.,8.]];
let split = data.split_at(Axis(0),1);
Getting the error:
method not found in `ndarray::ArrayBase<ndarray::data_repr::OwnedRepr<{float}>, ndarray::dimension::dim::Dim<[usize; 2]>>`
What am I missing here?
Upvotes: 3
Views: 945
Reputation: 160427
According to the documentation, these are defined only for ArrayView
s and not Array
s.
It's unfortunate that this is stated right above split_at
in the documentation, making it easy to miss if you simply click on it from the sidebar of methods.
Methods for read-only array views.
similarly for read-write views.
Initializing a view and splitting it as shown in split_at
's documentation should work fine.
Upvotes: 3