Closed
Description
There are a few operations that come up like this periodically (also rollaxis
). That said, some of these require a doc refresher on how they behave before using them. Still there can be value in doing something simpler than transpose that makes it clearer what changed. Perhaps an alternative approach to adding them to the spec is making sure the NumPy implementations play well with other array implementations.
Metadata
Metadata
Assignees
Type
Projects
Status
Stage 3
Activity
rgommers commentedon Sep 23, 2022
swapaxes
is problematic IIRC, see gh-228. That's why we called itpermute_dims
rgommers commentedon Sep 23, 2022
We would benefit from a description of how the many ways of doing this in numpy et al. translate to the preferred way of doing this with the array API. That will show also if there's a gap like
moveaxis
. IIRC we looked at this fairly carefully, however I cannot find it back right now.shoyer commentedon Sep 23, 2022
permute_dims
is the fundamental operation here.moveaxis
is convenient for users, but do we also want to include convenience functions in the API standard?rgommers commentedon Sep 25, 2022
I think we parked the many convenience functions previously, and focused on getting the one fundamental operation right. I'd say there is a case for one convenience function here though. Implementing
moveaxis
in terms ofpermute_dims
is not completely trivial. Looking at thenumpy.moveaxis
implementation, if you want to get negative axes and other corner cases right, it'd be something like:For the other functions mentioned:
rollaxis
is already doc-deprecated in numpy, in favor ofmoveaxis
.swapaxes
is simple to implement in terms ofmoveaxis
(but notpermute_dims
).