11import warnings
22from heapq import heapify as heapify , heappop as heappop , heappush as heappush , heappushpop as heappushpop
33from numbers import Integral as Integral , Real as Real
4- from typing import Any , Callable , ClassVar , Literal , TypeVar
4+ from typing import Any , Callable , ClassVar , Literal
5+ from typing_extensions import Self
56
67import numpy as np
78from joblib import Memory
@@ -21,9 +22,6 @@ from ..utils._param_validation import HasMethods as HasMethods, Hidden as Hidden
2122from ..utils .validation import check_memory as check_memory
2223from ._feature_agglomeration import AgglomerationTransform
2324
24- FeatureAgglomeration_Self = TypeVar ("FeatureAgglomeration_Self" , bound = FeatureAgglomeration )
25- AgglomerativeClustering_Self = TypeVar ("AgglomerativeClustering_Self" , bound = AgglomerativeClustering )
26-
2725###############################################################################
2826# Hierarchical tree building functions
2927
@@ -74,7 +72,7 @@ class AgglomerativeClustering(ClusterMixin, BaseEstimator):
7472 distance_threshold : None | Float = None ,
7573 compute_distances : bool = False ,
7674 ) -> None : ...
77- def fit (self : AgglomerativeClustering_Self , X : MatrixLike , y : Any = None ) -> AgglomerativeClustering_Self : ...
75+ def fit (self , X : MatrixLike , y : Any = None ) -> Self : ...
7876 def fit_predict (self , X : MatrixLike , y : Any = None ) -> ndarray : ...
7977
8078class FeatureAgglomeration (ClassNamePrefixFeaturesOutMixin , AgglomerativeClustering , AgglomerationTransform ):
@@ -103,5 +101,5 @@ class FeatureAgglomeration(ClassNamePrefixFeaturesOutMixin, AgglomerativeCluster
103101 distance_threshold : None | Float = None ,
104102 compute_distances : bool = False ,
105103 ) -> None : ...
106- def fit (self : FeatureAgglomeration_Self , X : MatrixLike , y : Any = None ) -> FeatureAgglomeration_Self : ...
104+ def fit (self , X : MatrixLike , y : Any = None ) -> Self : ...
107105 def fit_predict (self ): ...
0 commit comments