[SciPy-User] Numpy array slicing

Eirik Gjerløw eirik.gjerlow@astro.uio...
Thu Feb 9 03:54:05 CST 2012


Hello, this is (I think) a rather basic question about numpy slicing. I 
have the following code:

In [29]: a.shape
Out[29]: (3, 4, 12288, 2)

In [30]: mask.shape
Out[30]: (3, 12288)

In [31]: mask.dtype
Out[31]: dtype('bool')

In [32]: sum(mask[0])
Out[32]: 12285

In [33]: a[[0] + [slice(None)] + [mask[0]] + [slice(None)]].shape
Out[33]: (12285, 4, 2)

My question is: Why is not the final shape (4, 12285, 2) instead of 
(12285, 4, 2)?

Eirik Gjerløw


More information about the SciPy-User mailing list