Hi, there are np.flipud and np.fliplr methods to flip 2d arrays on the first and second dimension, respectively. What can I do to flip an array on an axis which I don't know before runtime? I'd really like to see a np.flip(arr, axis) method which lets me specify which axis to flip on. Any ideas? Cheers, Andreas.
Hi, On Wed, Jul 10, 2013 at 11:02 AM, Andreas Hilboll <lists@hilboll.de> wrote:
Hi,
there are np.flipud and np.fliplr methods to flip 2d arrays on the first and second dimension, respectively. What can I do to flip an array on an axis which I don't know before runtime? I'd really like to see a np.flip(arr, axis) method which lets me specify which axis to flip on.
I have something like that that's a few lines long: https://github.com/nipy/nibabel/blob/master/nibabel/orientations.py#L231 Cheers, Matthew
On 10.07.2013 17:06, Matthew Brett wrote:
Hi,
On Wed, Jul 10, 2013 at 11:02 AM, Andreas Hilboll <lists@hilboll.de> wrote:
Hi,
there are np.flipud and np.fliplr methods to flip 2d arrays on the first and second dimension, respectively. What can I do to flip an array on an axis which I don't know before runtime? I'd really like to see a np.flip(arr, axis) method which lets me specify which axis to flip on.
I have something like that that's a few lines long:
https://github.com/nipy/nibabel/blob/master/nibabel/orientations.py#L231
Cheers,
Matthew _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Thanks, Matthew! Should this go into numpy itself? If so, I could prepare a PR, if you point me to the right place (file) to put it. Cheers, Andreas.
On Wed, Jul 10, 2013 at 12:03 PM, Andreas Hilboll <lists@hilboll.de> wrote:
On 10.07.2013 17:06, Matthew Brett wrote:
Hi,
On Wed, Jul 10, 2013 at 11:02 AM, Andreas Hilboll <lists@hilboll.de> wrote:
Hi,
there are np.flipud and np.fliplr methods to flip 2d arrays on the first and second dimension, respectively. What can I do to flip an array on an axis which I don't know before runtime? I'd really like to see a np.flip(arr, axis) method which lets me specify which axis to flip on.
I have something like that that's a few lines long:
https://github.com/nipy/nibabel/blob/master/nibabel/orientations.py#L231
Cheers,
Matthew _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Thanks, Matthew! Should this go into numpy itself? If so, I could prepare a PR, if you point me to the right place (file) to put it.
Something like this would be nice to have in numpy, so we don't continue to reinvent it (e.g. https://github.com/scipy/scipy/blob/master/scipy/signal/_arraytools.py; see `axis_slice` and `axis_reverse`). Warren
Cheers, Andreas. _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
On Wed, Jul 10, 2013 at 5:03 PM, Andreas Hilboll <lists@hilboll.de> wrote:
On 10.07.2013 17:06, Matthew Brett wrote:
Hi,
On Wed, Jul 10, 2013 at 11:02 AM, Andreas Hilboll <lists@hilboll.de> wrote:
Hi,
there are np.flipud and np.fliplr methods to flip 2d arrays on the first and second dimension, respectively. What can I do to flip an array on an axis which I don't know before runtime? I'd really like to see a np.flip(arr, axis) method which lets me specify which axis to flip on.
I have something like that that's a few lines long:
https://github.com/nipy/nibabel/blob/master/nibabel/orientations.py#L231
Cheers,
Matthew _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Thanks, Matthew! Should this go into numpy itself?
Don't see why not.
If so, I could prepare a PR, if you point me to the right place (file) to put it.
I don't think there's a lot of rigid logic to how numpy's source is laid out. numpy/lib/function_base.py maybe, or next to flipud/fliplr in numpy/lib/twodim_base.py? -n
Am 10.07.2013 17:06, schrieb Matthew Brett:
Hi,
On Wed, Jul 10, 2013 at 11:02 AM, Andreas Hilboll <lists@hilboll.de> wrote:
Hi,
there are np.flipud and np.fliplr methods to flip 2d arrays on the first and second dimension, respectively. What can I do to flip an array on an axis which I don't know before runtime? I'd really like to see a np.flip(arr, axis) method which lets me specify which axis to flip on.
I have something like that that's a few lines long:
https://github.com/nipy/nibabel/blob/master/nibabel/orientations.py#L231
Cheers,
Matthew _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Hi Matthew, is it okay with you as the original author in nipy if I copy the flip_axis function to numpy, more or less verbatim, including tests? Cheers, Andreas.
participants (4)
-
Andreas Hilboll
-
Matthew Brett
-
Nathaniel Smith
-
Warren Weckesser