3

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?

1 Answer 1

3

According to the documentation, these are defined only for ArrayViews and not Arrays.

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.

Sign up to request clarification or add additional context in comments.

1 Comment

My concern about this is its memory usage, working with very large arrays, doubling memory usage is really not viable. Do you know the memory usage of this approach?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.