summaryrefslogtreecommitdiff
path: root/src/python/gudhi/clustering
diff options
context:
space:
mode:
authorMarc Glisse <marc.glisse@inria.fr>2020-05-25 17:32:17 +0200
committerMarc Glisse <marc.glisse@inria.fr>2020-05-25 17:32:17 +0200
commit8c122a8c92285dd89844720c9cf04d001db491d0 (patch)
treea9f228f405bfe3fb22c69d64f70d0f839bf75285 /src/python/gudhi/clustering
parent5be0f973261ce3999097923b573bbf63ec3a08f0 (diff)
bugs
Diffstat (limited to 'src/python/gudhi/clustering')
-rw-r--r--src/python/gudhi/clustering/tomato.py11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/python/gudhi/clustering/tomato.py b/src/python/gudhi/clustering/tomato.py
index 18425700..2b4d9242 100644
--- a/src/python/gudhi/clustering/tomato.py
+++ b/src/python/gudhi/clustering/tomato.py
@@ -132,10 +132,9 @@ class Tomato:
elif need_knn_dist:
knn_dist = knn
if self.density_type_ in ["DTM", "logDTM"]:
- if metric == "precomputed":
- dim = self.params_.get("dim", 2)
- else:
- dim = len(X)
+ dim = self.params_.get("dim")
+ if dim is None:
+ dim = len(X[0]) if metric != "precomputed" else 2
q = self.params_.get("q", dim)
weights = DTMDensity(k=k_DTM, metric="neighbors", dim=dim, q=q).fit_transform(knn_dist)
if self.density_type_ == "logDTM":
@@ -144,7 +143,7 @@ class Tomato:
if self.graph_type_ == "radius":
if metric in ["minkowski", "euclidean", "manhattan", "chebyshev"]:
from scipy.spatial import cKDTree
- tree t = cKDTree(X)
+ tree = cKDTree(X)
# TODO: handle "l1" and "l2" aliases?
p = self.params_.get("p")
if metric == "euclidean":
@@ -159,7 +158,7 @@ class Tomato:
elif p is None:
p = 2 # the default
eps = self.params_.get("eps", 0)
- self.neighbors_ = t.query_ball_tree(t, r=self.params_["r"], p=p, eps=eps)
+ self.neighbors_ = tree.query_ball_tree(tree, r=self.params_["r"], p=p, eps=eps)
# TODO: sklearn's NearestNeighbors.radius_neighbors can handle more metrics efficiently via its BallTree (don't bother with the _graph variant, it just calls radius_neighbors).
elif metric != "precomputed":