@@ -85,20 +85,13 @@ def mapper_labels(
8585 than those at position j.
8686
8787 :param X: A dataset of n points.
88- :type X: array-like of shape (n, m) or list-like of length n
8988 :param y: Lens values for the n points of the dataset.
90- :type y: array-like of shape (n, k) or list-like of length n
9189 :param cover: A cover algorithm.
92- :type cover: A class compatible with :class:`tdamapper.core.Cover`
9390 :param clustering: A clustering algorithm.
94- :type clustering: An estimator compatible with scikit-learn's clustering
95- interface, typically from :mod:`sklearn.cluster`.
9691 :param n_jobs: The maximum number of parallel clustering jobs. This
9792 parameter is passed to the constructor of :class:`joblib.Parallel`.
9893 Defaults to 1.
99- :type n_jobs: int
10094 :return: A list of node labels for each point in the dataset.
101- :rtype: list[list[int]]
10295 """
10396
10497 def _run_clustering (local_ids , X_local , clust ):
@@ -146,22 +139,15 @@ def mapper_connected_components(
146139 :func:`networkx.connected_components` on it.
147140
148141 :param X: A dataset of n points.
149- :type X: array-like of shape (n, m) or list-like of length n
150142 :param y: Lens values for the n points of the dataset.
151- :type y: array-like of shape (n, k) or list-like of length n
152143 :param cover: A cover algorithm.
153- :type cover: A class compatible with :class:`tdamapper.core.Cover`
154144 :param clustering: The clustering algorithm to apply to each subset of the
155145 dataset.
156- :type clustering: An estimator compatible with scikit-learn's clustering
157- interface, typically from :mod:`sklearn.cluster`.
158146 :param n_jobs: The maximum number of parallel clustering jobs. This
159147 parameter is passed to the constructor of :class:`joblib.Parallel`.
160148 Defaults to 1.
161- :type n_jobs: int
162149 :return: A list of labels. The label at position i identifies the connected
163150 component of the point at position i in the dataset.
164- :rtype: list[int]
165151 """
166152 itm_lbls = mapper_labels (X , y , cover , clustering , n_jobs = n_jobs )
167153 label_values = set ()
@@ -202,21 +188,14 @@ def mapper_graph(
202188 contained in the cluster.
203189
204190 :param X: A dataset of n points.
205- :type X: array-like of shape (n, m) or list-like of length n
206191 :param y: Lens values for the n points of the dataset.
207- :type y: array-like of shape (n, k) or list-like of length n
208192 :param cover: A cover algorithm.
209- :type cover: A class compatible with :class:`tdamapper.core.Cover`
210193 :param clustering: The clustering algorithm to apply to each subset of the
211194 dataset.
212- :type clustering: An estimator compatible with scikit-learn's clustering
213- interface, typically from :mod:`sklearn.cluster`.
214195 :param n_jobs: The maximum number of parallel clustering jobs. This
215196 parameter is passed to the constructor of :class:`joblib.Parallel`.
216197 Defaults to 1.
217- :type n_jobs: int
218198 :return: The Mapper graph.
219- :rtype: :class:`networkx.Graph`
220199 """
221200 itm_lbls = mapper_labels (X , y , cover , clustering , n_jobs = n_jobs )
222201 graph = nx .Graph ()
@@ -253,13 +232,9 @@ def aggregate_graph(X: ArrayLike, graph: nx.Graph, agg: Callable) -> Dict:
253232 and the values are the aggregation values.
254233
255234 :param X: A dataset of n points.
256- :type X: array-like of shape (n, m) or list-like of length n
257235 :param graph: The graph to apply the aggregation function to.
258- :type graph: :class:`networkx.Graph`.
259236 :param agg: The aggregation function to use.
260- :type agg: Callable.
261237 :return: A dictionary of node-aggregation pairs.
262- :rtype: dict
263238 """
264239 agg_values = {}
265240 nodes = graph .nodes ()
@@ -286,7 +261,6 @@ def fit(self, X: ArrayLike) -> SpatialSearch:
286261 Fit the spatial search algorithm to the data.
287262
288263 :param X: A dataset of n points.
289- :type X: array-like of shape (n, m) or list-like of length n
290264 :return: self
291265 """
292266
@@ -295,9 +269,7 @@ def search(self, x: PointLike) -> List[int]:
295269 Search for the nearest neighbors of a point.
296270
297271 :param x: A point to search for.
298- :type x: A point-like object, such as a list or a numpy array.
299272 :return: A list of indices of the nearest neighbors of the point.
300- :rtype: list[int]
301273 """
302274
303275
@@ -317,7 +289,6 @@ def fit(self, X: ArrayLike) -> Cover:
317289 Fit the cover algorithm to the data.
318290
319291 :param X: A dataset of n points.
320- :type X: array-like of shape (n, m) or list-like of length n
321292 :return: self
322293 """
323294
@@ -329,7 +300,6 @@ def fit_transform(self, X: ArrayLike) -> Generator[List[int], None, None]:
329300 the indices of the points in the dataset that belong to the open set.
330301
331302 :param X: A dataset of n points.
332- :type X: array-like of shape (n, m) or list-like of length n
333303 :yield: A generator of lists of indices.
334304 """
335305
@@ -341,7 +311,6 @@ def transform(self, X: ArrayLike) -> Generator[List[int], None, None]:
341311 the indices of the points in the dataset that belong to the open set.
342312
343313 :param X: A dataset of n points.
344- :type X: array-like of shape (n, m) or list-like of length n
345314 :yield: A generator of lists of indices.
346315 """
347316
@@ -374,7 +343,6 @@ def fit(self, X: ArrayLike, y: Any = None) -> Clustering:
374343 Fit the clustering algorithm to the data.
375344
376345 :param X: A dataset of n points.
377- :type X: array-like of shape (n, m) or list-like of length n
378346 :param y: Ignored.
379347 :return: self
380348 """
@@ -402,6 +370,13 @@ def fit_transform(self, X: ArrayLike) -> Generator[List[int], None, None]:
402370
403371class _MapperAlgorithm (EstimatorMixin , ParamsMixin ):
404372
373+ _cover : Cover
374+ _clustering : Clustering
375+ _verbose : bool
376+ _failsafe : bool
377+ _n_jobs : int
378+ graph_ : nx .Graph
379+
405380 def __init__ (
406381 self ,
407382 cover : Optional [Cover ] = None ,
@@ -472,13 +447,14 @@ class FailSafeClustering(ParamsMixin):
472447 returned. This can be useful for robustness and debugging purposes.
473448
474449 :param clustering: A clustering algorithm to delegate to.
475- :type clustering: An estimator compatible with scikit-learn's clustering
476- interface, typically from :mod:`sklearn.cluster`.
477450 :param verbose: A flag to log clustering exceptions. Set to True to
478451 enable logging, or False to suppress it. Defaults to True.
479- :type verbose: bool, optional.
480452 """
481453
454+ _clustering : Clustering
455+ _verbose : bool
456+ labels_ : List [int ]
457+
482458 def __init__ (self , clustering : Optional [Clustering ] = None , verbose : bool = True ):
483459 self .clustering = clustering
484460 self .verbose = verbose
@@ -488,7 +464,7 @@ def fit(self, X: ArrayLike, y: Optional[ArrayLike] = None):
488464 TrivialClustering () if self .clustering is None else self .clustering
489465 )
490466 self ._verbose = self .verbose
491- self .labels_ = None
467+ self .labels_ = []
492468 try :
493469 self ._clustering .fit (X , y )
494470 self .labels_ = self ._clustering .labels_
@@ -509,15 +485,16 @@ class TrivialClustering(ParamsMixin):
509485 construction of the Mapper graph.
510486 """
511487
488+ labels_ : List [int ]
489+
512490 def __init__ (self ):
513491 pass
514492
515- def fit (self , X : ArrayLike , y : Optional [ArrayLike ] = None ) -> TrivialClustering :
493+ def fit (self , X : ArrayLike , _ : Optional [ArrayLike ] = None ) -> TrivialClustering :
516494 """
517495 Fit the clustering algorithm to the data.
518496
519497 :param X: A dataset of n points.
520- :type X: array-like of shape (n, m) or list-like of length n
521498 :param y: Ignored.
522499 :return: self
523500 """
0 commit comments