When I run this code:
import numpy as np
a = np.array([1, 2, 3, 4, 5, 6])
print(np.where(a > 2))
it would be natural to get an array of indices where a > 2, i.e. [2, 3, 4, 5], but instead we get:
(array([2, 3, 4, 5], dtype=int64),)
i.e. a tuple with empty second member.
Then, to get the the "natural" answer of numpy.where, we have to do:
np.where(a > 2)[0]
What's the point in this tuple? In which situation is it useful?
Note: I'm speaking here only about the use case numpy.where(cond) and not numpy.where(cond, x, y) that also exists (see documentation).