[Numpy-discussion] Does x[True] trigger basic or advanced indexing?
wieser.eric+numpy at gmail.com
Wed Dec 13 15:49:56 EST 2017
Increasingly, NumPy does not considers booleans to be integer types, and
indexing is one of these cases.
So no, it will not be treated as a tuple of integers, but as a 0d mask
On Wed, 13 Dec 2017 at 12:44 Joe <solarjoe at posteo.org> wrote:
> yet another question.
> I looked through the indexing rules in the
> documentation but I count not find which one
> applies to x[True] and x[False]
> that might e.g result from
> import numpy as np
> x = np.array(3)
> x = np.random.rand(2,3)
> I understood that they are equivalent to
> I tested it and it looks like advanced indexing,
> but I try to unterstand the logic behind this,
> if there is any :)
> In x[x<1] the x<1 is a mask and thus I guess it is a
> "tuple with at least one sequence object or ndarray (of data type
> integer or bool)", right?
> Or will x[True] trigger basic indexing as it is "a tuple of integers"
> because True will be converted to Int?
> NumPy-Discussion mailing list
> NumPy-Discussion at python.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion