Added diagnosed conditions in compute_knn_distances