Skip to content

Instantly share code, notes, and snippets.

@durden
Created March 14, 2014 14:04
Show Gist options
  • Save durden/9548281 to your computer and use it in GitHub Desktop.
Save durden/9548281 to your computer and use it in GitHub Desktop.
Python numpy array ordering
>>> import numpy
>>> x = numpy.arange(27).reshape((3,3,3))
>>> x
array([[[ 0, 1, 2],
[ 3, 4, 5],
[ 6, 7, 8]],
[[ 9, 10, 11],
[12, 13, 14],
[15, 16, 17]],
[[18, 19, 20],
[21, 22, 23],
[24, 25, 26]]])
>>> y = numpy.arange(27).reshape((3,3,3), order='F')
>>> print y
[[[ 0 9 18]
[ 3 12 21]
[ 6 15 24]]
[[ 1 10 19]
[ 4 13 22]
[ 7 16 25]]
[[ 2 11 20]
[ 5 14 23]
[ 8 17 26]]]
>>>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment