def generate_matches_array(labels):
"""
Return an array of bool in the same order as the distances from
`scipy.spatial.distance.pdist` indicating whether a distance is for
matching or non-matching labels.
"""
N = len(labels)
matches = np.zeros(N * (N - 1) / 2, dtype=np.bool)
# For every distance, mark whether it is a true match or not
cur_matches_i = 0
for n in range(N):
cur_label = labels[n]
matches[cur_matches_i:cur_matches_i + (N - n) - 1] = np.asarray(labels[n + 1:]) == cur_label
cur_matches_i += N - n - 1
return matches
samediff.py 文件源码
python
阅读 24
收藏 0
点赞 0
评论 0
评论列表
文章目录