I'm porting a program from #MATLAB to #NumPy and I need help with indexing.

The best way I've found so far is to use negative indexes with NumPy while switching X and Y dimensions. It feels really hackish and looks ugly, tho. Is there a better way?

Server run by the main developers of the project It is not focused on any particular niche interest - everyone is welcome as long as you follow our code of conduct!

Valtteri@valdemartti@mastodon.socialWith examples:

Dimension order

M: (y, x, z, t)

N: (t, z, y, x)

Indexing

a(1) => a[-2]

a(2) => a[-1]

a(3) => a[-3]

a(4) => a[-4]