In exercise 2, for the compute_centroids function, what does this line do exactly? (having a bit of trouble to understand the syntax)

**points = X[idx == k]**

X and idx are arrays, k is an integer. `idx==k`

checks each element in the array `idx`

whether the element is equal to `k`

, returning an array of booleans (True / False), for example `idx==k`

may give us an array like `np.array([True, False, True, False])`

indicating the results of the checks element-wise. X takes the checking result and filters its own element with the checking results - leaving only element where the cooresponding check is `True`

. For example, if `X`

is `np.array([4,5,6,7])`

, then `X[idx==k]`

will give us `np.array([4, 6])`

because only the zeroth and the second checking results are `True`

.

Raymond