@@ -115,47 +115,48 @@ def asPointwise(data, class_instance, precomputed_knn=None, n_neighbors=100, n_j
115115 return np .array ([class_instance .fit (data [i , :]).dimension_ for i in knn ])
116116
117117
118- class DocInheritorBase (type ):
119- """ A metaclass to append GlobalEstimator or LocalEstimator Attributes section docstring to each estimator"""
120-
121- def __new__ (mcs , class_name , class_bases , class_dict ):
122- # inherit class docstring: the docstring is constructed by traversing
123- # the mro for the class and merging their docstrings, with each next
124- # docstring as serving as the 'parent', and the accumulated docstring
125- # serving as the 'child'
126- this_doc = class_dict .get ("__doc__" , None )
127- for mro_cls in (mro_cls for base in class_bases for mro_cls in base .mro ()):
128- prnt_cls_doc = mro_cls .__doc__
129- if prnt_cls_doc is not None :
130- if prnt_cls_doc == "The most base type" :
131- prnt_cls_doc = None
132- this_doc = mcs .class_doc_inherit (prnt_cls_doc , this_doc )
133-
134- class_dict ["__doc__" ] = this_doc
135-
136- return type .__new__ (mcs , class_name , class_bases , class_dict )
137-
138- @staticmethod
139- def class_doc_inherit (prnt_doc , child_doc ):
140- """ Merge the docstrings of a parent class and its child.
141- Parameters
142- ----------
143- prnt_cls_doc: Union[None, str]
144- child_doc: Union[None, str]
145- """
146- if prnt_doc is None or "dimension_" not in prnt_doc :
147- return child_doc
148- else :
149- if "Attributes" in child_doc :
150- prnt_doc_attr = prnt_doc .index ("dimension_" )
151- child_doc = child_doc + prnt_doc [prnt_doc_attr :] + "\n "
152- else :
153- prnt_doc_attr = prnt_doc .index ("Attributes" )
154- child_doc = child_doc + "\n " + prnt_doc [prnt_doc_attr :]
155- return child_doc
156-
157-
158- class GlobalEstimator (BaseEstimator , metaclass = DocInheritorBase ):
118+ # class DocInheritorBase(type):
119+ # """ A metaclass to append GlobalEstimator or LocalEstimator Attributes section docstring to each estimator"""
120+ #
121+ # def __new__(mcs, class_name, class_bases, class_dict):
122+ # # inherit class docstring: the docstring is constructed by traversing
123+ # # the mro for the class and merging their docstrings, with each next
124+ # # docstring as serving as the 'parent', and the accumulated docstring
125+ # # serving as the 'child'
126+ # this_doc = class_dict.get("__doc__", None)
127+ # for mro_cls in (mro_cls for base in class_bases for mro_cls in base.mro()):
128+ # prnt_cls_doc = mro_cls.__doc__
129+ # if prnt_cls_doc is not None:
130+ # if prnt_cls_doc == "The most base type":
131+ # prnt_cls_doc = None
132+ # this_doc = mcs.class_doc_inherit(prnt_cls_doc, this_doc)
133+ #
134+ # class_dict["__doc__"] = this_doc
135+ #
136+ # return type.__new__(mcs, class_name, class_bases, class_dict)
137+ #
138+ # @staticmethod
139+ # def class_doc_inherit(prnt_doc, child_doc):
140+ # """ Merge the docstrings of a parent class and its child.
141+ #
142+ # Parameters
143+ # ----------
144+ # prnt_cls_doc: Union[None, str]
145+ # child_doc: Union[None, str]
146+ # """
147+ # if prnt_doc is None or "dimension_" not in prnt_doc:
148+ # return child_doc
149+ # else:
150+ # if "Attributes" in child_doc:
151+ # prnt_doc_attr = prnt_doc.index("dimension_")
152+ # child_doc = child_doc + prnt_doc[prnt_doc_attr:] + "\n"
153+ # else:
154+ # prnt_doc_attr = prnt_doc.index("Attributes")
155+ # child_doc = child_doc + "\n " + prnt_doc[prnt_doc_attr:]
156+ # return child_doc
157+
158+
159+ class GlobalEstimator (BaseEstimator ): # , metaclass=DocInheritorBase):
159160 """ Template base class: inherit BaseEstimator, define predict, fit_predict, fit_pw, predict_pw, fit_predict_pw
160161
161162 Attributes
@@ -190,6 +191,7 @@ def predict(self, X=None):
190191
191192 def fit_predict (self , X , y = None ):
192193 """Fit estimator and return ID
194+
193195 Parameters
194196 ----------
195197 X : {array-like}, shape (n_samples, n_features)
@@ -203,8 +205,7 @@ def fit_predict(self, X, y=None):
203205 return self .fit (X ).dimension_
204206
205207 def fit_pw (self , X , precomputed_knn = None , smooth = False , n_neighbors = 100 , n_jobs = 1 ):
206- """
207- Creates an array of pointwise ID estimates (self.dimension_pw_) by fitting the estimator in kNN of each point.
208+ """Creates an array of pointwise ID estimates (self.dimension_pw_) by fitting the estimator in kNN of each point.
208209
209210 Parameters
210211 ----------
@@ -220,6 +221,7 @@ def fit_pw(self, X, precomputed_knn=None, smooth=False, n_neighbors=100, n_jobs=
220221 Additionally computes a smoothed version of pointwise estimates by
221222 taking the ID of a point as the average ID of each point in its neighborhood (self.dimension_pw_)
222223 smooth_
224+
223225 Returns
224226 -------
225227 self : object
@@ -282,8 +284,7 @@ def predict_pw(self, X=None):
282284 def fit_predict_pw (
283285 self , X , precomputed_knn = None , smooth = False , n_neighbors = 100 , n_jobs = 1
284286 ):
285- """
286- Returns an array of pointwise ID estimates by fitting the estimator in kNN of each point.
287+ """Returns an array of pointwise ID estimates by fitting the estimator in kNN of each point.
287288
288289 Parameters
289290 ----------
@@ -334,7 +335,7 @@ def fit_predict_pw(
334335 return dimension_pw_
335336
336337
337- class LocalEstimator (BaseEstimator , metaclass = DocInheritorBase ):
338+ class LocalEstimator (BaseEstimator ): # , metaclass=DocInheritorBase):
338339 """ Template base class: generic _fit, fit, predict_pw for local ID estimators
339340
340341 Attributes
@@ -369,6 +370,7 @@ def fit(
369370 n_jobs = 1 ,
370371 ):
371372 """Fitting method for local ID estimators
373+
372374 Parameters
373375 ----------
374376 X : {array-like}, shape (n_samples, n_features)
@@ -457,6 +459,7 @@ def fit_predict(
457459 n_jobs = 1 ,
458460 ):
459461 """Fit-predict method for local ID estimators
462+
460463 Parameters
461464 ----------
462465 X : {array-like}, shape (n_samples, n_features)
0 commit comments