I am experimenting with the numpy.where(condition[, x, y])
function.
From the numpy documentation, I learn that if you give just one array as input, it shou
Short answer: np.where
is designed to have consistent output regardless of the dimension of the array.
A two-dimensional array has two indices, so the result of np.where
is a length-2 tuple containing the relevant indices. This generalizes to a length-3 tuple for 3-dimensions, a length-4 tuple for 4 dimensions, or a length-N tuple for N dimensions. By this rule, it is clear that in 1 dimension, the result should be a length-1 tuple.