[Numpy-discussion] Classes as records within an numpy array

Sturla Molden sturla at molden.no
Sun Apr 10 22:17:04 EDT 2011

Den 11.04.2011 03:59, skrev David Crisp:
> Is it a significant problem if I use the x[i][j] method and not the
> x[i,j] method?  Or are we talking about trying to stick with a
> convention?

It is a significant problem.

Consider that x[i][j] means ( x[i] )[j]. Then consider that x[i] in your 
case returns an instance of Record, not ndarray.

If you want 2D indexing on an ndarray, it should be written as x[i,j]. A 
2D NumPY array is not an array of arrays.

If you work with nested Python lists, you should index x[i][j], because 
x[i] will return a list.


More information about the NumPy-Discussion mailing list