I have a question about the “Closest Negative” code in the lecture notebook.

Notice that this code from the NB does not actually print sim_ap, in prints np.diag(sim_ap).

sim_ap = np.diag(sim)

print(“sim_ap :”)

print(np.diag(sim_ap), “\n”)

If I visually construct the mask matrix using the matrix printed here as sim_ap, I get a different result than the mask matrix the code produces. If I use “sim_an > sim_ap”, with sim_ap as printed, to construct mask_2 this is ‘T’ where the off-diag elements of sim are positive and where the diag elements are negative. So visually constructing mask_2 I get:

F F T F

F F T F

T T T F

F F F F

However, the code uses the command “mask_2 = sim_an > sim_ap.reshape(b, 1)”. This produces a different mask_2 than my visual inspection using sim_an > sim_ap. Is the code correct? If so, it would make sense to modify the comments and the output to match the code. Or am I missing something?

Thank you