[Numpy-discussion] Re: slice an array along specific axis

2025-02-01 Thread Benjamin Root via NumPy-Discussion
When I usually need to do something like that, I just construct a tuple of slice() objects. No need to use swapaxes(). Or am I missing something? On Sat, Feb 1, 2025 at 10:24 AM Michael Mullen wrote: > Hello, > > I am writing a class handling NumPy arrays, and basing it off some > computations I

[Numpy-discussion] slice an array along specific axis

2025-02-01 Thread Michael Mullen
Hello, I am writing a class handling NumPy arrays, and basing it off some computations I have done in C++ using the Eigen library. For tensors whose length are only known at runtime, the Eigen chip method is useful for slicing a tensor along a specific axis while keeping all other axes the same. I