'The dimension orders of the Numpy 3D array are designed to z, x, y. Are there any advantages?

I think that the x,y,z order is more intuitive for a 3D array, just as Matlab does. For example, If someone tells me an array is 2x3x4, I will think it is 2 rows, 3 columns, 4 frames, instead of 2 frames, 3 rows, 4 columns.

Is there any core reason why the creators of NumPy had to do this?



Solution 1:[1]

@hpaulj You mentioned that the default input of the Numpy array is the nesting of lists. It inspires me.

For a nesting list,

l=[
    [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]],
    [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]
]

len(l)  # 2
len(l[0])  # 3
len(l[0][0]) # 4

its order of the length keeps consistency with the shape of the Numpy array.

np.array(l).shape  # (2, 3, 4)

Maybe that is the reason.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jerry Chou