[SciPy-User] Numpy array slicing

Oleksandr Huziy guziy.sasha@gmail....
Thu Feb 9 11:13:19 CST 2012


Hi, what will happen if you do:

a[[0] + [slice(None)] + [[mask[0]]] + [slice(None)]].shape

please, give the code to generate the mask and the array, so we could
test our hypotheses.
thanks

--
Oleksandr Huziy

2012/2/9 Eirik Gjerløw <eirik.gjerlow@astro.uio.no>:
> 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
> _______________________________________________
> SciPy-User mailing list
> SciPy-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user


More information about the SciPy-User mailing list