[Numpy-discussion] Logical indexing and higher-dimensional arrays.
Stéfan van der Walt
Wed Feb 8 02:55:31 CST 2012
On Tue, Feb 7, 2012 at 9:01 PM, Travis Oliphant <firstname.lastname@example.org> wrote:
> like so: x[ind1, :, ind2], the question is what should the shape of the output me. If ind1 is a scalar there is no ambiguity (and this should be special cased --- but unfortunately isn't).
x.shape == (a0, a1, a2)
ind1.shape == (b0, 1, 1)
ind2.shape == (1, 1, b1)
then an expected output shape for x[ind1, :, ind2] could be (b0, a1,
b1). At the moment it is (b0, 1, b1, a1). The logic would be fairly
straightforward, something akin to:
out_shape = list(np.broadcast_arrays(ind1, ind2).shape)
out_shape[colon_positions] = x.shape[colon_positions]
More information about the NumPy-Discussion