4D arrays
Manolo Martínez
manolo at austrohungaro.com
Wed Dec 2 04:17:17 EST 2015
On 12/01/15 at 06:47pm, Peter Otten wrote:
> Extract 2D arrays:
>
> >>> a[:,2,3]
> array([[ 55, 56, 57, 58, 59],
> [115, 116, 117, 118, 119]])
> >>> a[1,:,2]
> array([[ 70, 71, 72, 73, 74],
> [ 90, 91, 92, 93, 94],
> [110, 111, 112, 113, 114]])
The first one is equivalent to a[:, 2, 3, :], which is perhaps clearer
in this context: you are singling out row 2 in axis 1, and row 3 in axis
2, and taking everything from axes 0 and 3.
Mutatis mutandis with the second example and a[1, :, 2, :], which is
different from a[1, :, :, 2], etc.
Manolo
More information about the Python-list
mailing list