Skip to content

Commit

Permalink
Fix sparse jaccard distance as well (issue #33)
Browse files Browse the repository at this point in the history
  • Loading branch information
lmcinnes committed Dec 5, 2017
1 parent b7ba989 commit 296c249
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions umap/sparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -584,8 +584,11 @@ def sparse_bray_curtis(ind1, data1, ind2, data2):
def sparse_jaccard(ind1, data1, ind2, data2):
num_non_zero = arr_union(ind1, ind2).shape[0]
num_equal = arr_intersect(ind1, ind2).shape[0]

return float(num_non_zero - num_equal) / num_non_zero

if num_non_zero == 0:
return 0.0
else:
return float(num_non_zero - num_equal) / num_non_zero


@numba.njit()
Expand Down

0 comments on commit 296c249

Please sign in to comment.