Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_precomputed(self):
mapper = KeplerMapper()
X = np.random.rand(100, 2)
X_pdist = distance.squareform(distance.pdist(X, metric="euclidean"))
lens = mapper.fit_transform(X_pdist)
graph = mapper.map(
lens,
X=X_pdist,
cover=Cover(n_cubes=10, perc_overlap=0.8),
clusterer=cluster.DBSCAN(metric="precomputed", min_samples=3),
precomputed=True,
)
graph2 = mapper.map(
lens,
X=X,
cover=Cover(n_cubes=10, perc_overlap=0.8),
clusterer=cluster.DBSCAN(metric="euclidean", min_samples=3),
)
assert graph["links"] == graph2["links"]
assert graph["nodes"] == graph2["nodes"]
assert graph["simplices"] == graph2["simplices"]