Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"""Simple implementation for when you don't need incremental updates."""
n = len(data)
distance_matrix = scipy.sparse.lil_matrix((n, n))
def decorated_d(i, j):
res = d(data[i], data[j])
distance_matrix[i, j] = distance_matrix[j, i] = res
return res
the_hnsw = hnsw.HNSW(decorated_d, m, ef, m0, level_mult, heuristic)
add = the_hnsw.balanced_add if balanced_add else the_hnsw.add
for i in range(len(data)):
add(i)
return hdbscan.hdbscan(distance_matrix, metric='precomputed', **kwargs)