-
Notifications
You must be signed in to change notification settings - Fork 347
Closed
Labels
Description
A somewhat frequently-requested feature (e.g. #197, #590, #607) is to provide methods to create Array instances from nested Vec and/or ArrayBase instances (e.g. Array2<A> from Vec<Vec<A>> or Array3<A> from Vec<Array2<A>>).
Note that it's generally advisable to avoid nested Vec/ArrayBase types like this because they require extra heap allocations, can scatter data all over memory, cause unnecessary indirection, fail to enforce consistent shape within the nested Vecs/ArrayBases, and are generally more difficult to work with.
I think we should:
- Improve the documentation to explain why these nested data structures are best avoided and the best way to handle the use cases (primarily constructing an
Arrayby appending rows). - For users who need to use nested data structures anyway, either add the methods to perform the conversions or suggest how they could perform the conversion manually. (
data.iter().flatten().cloned().collect::<Vec<_>>()followed byfrom_shape_vecseems pretty clean if the user is confident that the nestedVecs/ArrayBases are all the same length/shape).
cafeclimber