Skip to content

Commit 2ccce2d

Browse files
committed
add rewrite of minimal cluster sampling in order to allow precomputed distance matrices. This fixes crash when using clustering distance treshold, which is without a fixed number of clusters.
1 parent 0711d80 commit 2ccce2d

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

kmapper/kmapper.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -500,17 +500,19 @@ def map(
500500
# we consider clustering or skipping it.
501501
cluster_params = clusterer.get_params()
502502

503-
min_cluster_samples = cluster_params.get(
504-
"n_clusters",
505-
cluster_params.get(
506-
"min_cluster_size", cluster_params.get("min_samples", 1)
507-
),
508-
)
503+
if precomputed:
504+
min_cluster_samples = 2
505+
else:
506+
min_cluster_samples = cluster_params.get(
507+
"n_clusters",
508+
cluster_params.get(
509+
"min_cluster_size", cluster_params.get("min_samples", 1)
510+
),
511+
)
509512

510513
if self.verbose > 1:
511514
print(
512-
"Minimal points in hypercube before clustering: %d"
513-
% (min_cluster_samples)
515+
"Minimal points in hypercube before clustering: {}".format(min_cluster_samples)
514516
)
515517

516518
# Subdivide the projected data X in intervals/hypercubes with overlap

0 commit comments

Comments
 (0)