Closed Ivorforce closed 1 month ago
While xtensor has .resize()
, it does not preserve elements (unlike NumPy .resize()
).
Additionally, views would be invalidated when an array is resized or appended to. In NumPy, resizing an array that has 'active' views on it raises an error.
Therefore, in-place array manipulation is not in scope. It is more honest to let people instantiate new arrays with more elements.
A problem will be posed by #42. In that case, we should either be agnostic of the array size, or automatically invalidate ourselves when the target changes in size.
I think i have a good solution for stacks: Just call nd.moveaxis(nd.array(arg), 0, axis)
.
I think that should be equivalent. To make it perfectly contiguous it needs some more work, but that's optimization - not a priority yet.
likewise, unstack is equivalent to nd.moveaxis(arg, axis, 0)
.
I think this is enough for the moment. Array manipulation now has a lot more capability in NumDot. Missing functions can be added as needed.
Xtensor has support for all of this, so it's feasible to implement. Though a lot is about not doing work twice, so we probably have to reimplement some functions to avoid first allocating half-done arrays and only joining at a later step.
To complete this issue: