Hellos,
I would like to propose `numpy.ndarray.permute_shape(<permuted_shape>)` method
to predictably permute the shape of an ndarray. In my opinion, the current
alternatives (`swapaxes`, `transform`, `moveaxes` and friends) are
counterintuitive and rely on referring to the axis indices. It would be
abundantly helpful to have something like reshape but which moves the data
around (unlike reshape, which doesn't).
Scenario: structural biology uses MRC files, which define a number of fields
that describe a 3D volume. There is a field which describes the dimensions of
the 3D image and another which associates each image axis with a physical axis.
There are six such assignments between the image shape and the axes assignments
(if we keep the shape fixed we can assign XYZ, XZY, YXZ, YZX, ZXY, ZYX to the
columns, rows and stacks) and working out how to correctly transform the data
is generally non-trivial. I've written a package
(https://github.com/emdb-empiar/maptools) which does this but I use swapaxes to
reorient the 3D image. It would be so much easier to use
`numpy.ndarray.permute_shape(<permuted_shape>)` instead.
Any thoughts? Also, any helpful hints on how to get started with such a
contribution would be helpful.
Paul
_______________________________________________
NumPy-Discussion mailing list -- numpy-discussion@python.org
To unsubscribe send an email to numpy-discussion-le...@python.org
https://mail.python.org/mailman3/lists/numpy-discussion.python.org/
Member address: arch...@mail-archive.com