summaryrefslogtreecommitdiff
path: root/src/python/gudhi/point_cloud
diff options
context:
space:
mode:
authorMarc Glisse <marc.glisse@inria.fr>2020-04-14 18:27:19 +0200
committerMarc Glisse <marc.glisse@inria.fr>2020-04-14 18:27:19 +0200
commit9518287cfa2a62948ede2e7d17d5c9f29092e0f4 (patch)
treeafa7c1eb5217528b92f4f51b93815108537a067a /src/python/gudhi/point_cloud
parentb908205e85bbe29c8d18ad1f38e783a1327434d7 (diff)
Doc improvements
Diffstat (limited to 'src/python/gudhi/point_cloud')
-rw-r--r--src/python/gudhi/point_cloud/dtm.py12
-rw-r--r--src/python/gudhi/point_cloud/knn.py11
2 files changed, 18 insertions, 5 deletions
diff --git a/src/python/gudhi/point_cloud/dtm.py b/src/python/gudhi/point_cloud/dtm.py
index 38368f29..58dec536 100644
--- a/src/python/gudhi/point_cloud/dtm.py
+++ b/src/python/gudhi/point_cloud/dtm.py
@@ -20,7 +20,9 @@ class DistanceToMeasure:
Args:
k (int): number of neighbors (possibly including the point itself).
q (float): order used to compute the distance to measure. Defaults to 2.
- kwargs: same parameters as :class:`~gudhi.point_cloud.knn.KNearestNeighbors`, except that metric="neighbors" means that :func:`transform` expects an array with the distances to the k nearest neighbors.
+ kwargs: same parameters as :class:`~gudhi.point_cloud.knn.KNearestNeighbors`, except that
+ metric="neighbors" means that :func:`transform` expects an array with the distances
+ to the k nearest neighbors.
"""
self.k = k
self.q = q
@@ -44,7 +46,13 @@ class DistanceToMeasure:
def transform(self, X):
"""
Args:
- X (numpy.array): coordinates for query points, or distance matrix if metric is "precomputed", or distances to the k nearest neighbors if metric is "neighbors" (if the array has more than k columns, the remaining ones are ignored).
+ X (numpy.array): coordinates for query points, or distance matrix if metric is "precomputed",
+ or distances to the k nearest neighbors if metric is "neighbors" (if the array has more
+ than k columns, the remaining ones are ignored).
+
+ Returns:
+ numpy.array: a 1-d array with, for each point of X, its distance to the measure defined
+ by the argument of :func:`fit`.
"""
if self.params["metric"] == "neighbors":
distances = X[:, : self.k]
diff --git a/src/python/gudhi/point_cloud/knn.py b/src/python/gudhi/point_cloud/knn.py
index 8b3cdb46..d7cf0b2a 100644
--- a/src/python/gudhi/point_cloud/knn.py
+++ b/src/python/gudhi/point_cloud/knn.py
@@ -38,9 +38,9 @@ class KNearestNeighbors:
sort_results (bool): if True, then distances and indices of each point are
sorted on return, so that the first column contains the closest points.
Otherwise, neighbors are returned in an arbitrary order. Defaults to True.
- enable_autodiff (bool): if the input is a torch.tensor, jax.numpy.array or similar, this instructs
- the function to compute distances in a way that works with automatic differentiation.
- This is experimental and not supported for all implementations.
+ enable_autodiff (bool): if the input is a torch.tensor, jax.numpy.ndarray or tensorflow.Tensor, this
+ instructs the function to compute distances in a way that works with automatic differentiation.
+ This is experimental and not supported for all metrics. Defaults to False.
kwargs: additional parameters are forwarded to the backends.
"""
self.k = k
@@ -124,6 +124,11 @@ class KNearestNeighbors:
"""
Args:
X (numpy.array): coordinates for query points, or distance matrix if metric is "precomputed".
+
+ Returns:
+ numpy.array: if return_index, an array of shape (len(X), k) with the indices (in the argument
+ of :func:`fit`) of the k nearest neighbors to the points of X. If return_distance, an array of the
+ same shape with the distances to those neighbors. If both, a tuple with the two arrays, in this order.
"""
if self.params.get("enable_autodiff", False):
# pykeops does not support autodiff for kmin yet, but when it does in the future,