I think the L2_distances in the function _nearest_neighbourcorrect should be computed as follows:
dis = pairs[0][i] - pairs[1][i]dis = dis.reshape(dis.size)L2_distances[i] = np.sqrt(dis.dot(dis))
instead of
L2_distances[i] = np.sum(np.sqrt(pairs[0][i]**2 - pairs[1][i]**2))
I think the L2_distances in the function _nearest_neighbourcorrect should be computed as follows:
dis = pairs[0][i] - pairs[1][i]
dis = dis.reshape(dis.size)
L2_distances[i] = np.sqrt(dis.dot(dis))
instead ofL2_distances[i] = np.sum(np.sqrt(pairs[0][i]**2 - pairs[1][i]**2))