Skip to content

Commit

Permalink
Fix abstractmethod errors
Browse files Browse the repository at this point in the history
  • Loading branch information
J535D165 committed Jul 19, 2023
1 parent b346288 commit a3c2298
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
8 changes: 4 additions & 4 deletions recordlinkage/adapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ def _predict(self, features):
try:
prediction = self.kernel.predict(features)
except NotFittedError as err:
raise NotFittedError from err(
raise NotFittedError(
"{} is not fitted yet. Call 'fit' with appropriate "
"arguments before using this method.".format(type(self).__name__)
)
) from err

return prediction

Expand Down Expand Up @@ -109,10 +109,10 @@ def _predict(self, features):
try:
prediction = self.kernel.predict_classes(features)[:, 0]
except NotFittedError as err:
raise NotFittedError from err(
raise NotFittedError(
"{} is not fitted yet. Call 'fit' with appropriate "
"arguments before using this method.".format(type(self).__name__)
)
) from err

return prediction

Expand Down
6 changes: 2 additions & 4 deletions recordlinkage/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,6 @@ def learn(self, *args, **kwargs):
)
return self.fit_predict(*args, **kwargs)

@abstractmethod
def _initialise_classifier(self, comparison_vectors):
"""Initialise the classifier.
Expand All @@ -877,7 +876,7 @@ def _initialise_classifier(self, comparison_vectors):
comparison_vectors : pandas.DataFrame
The comparison vectors (or features) to fit the classifier with.
"""
pass
return

@abstractmethod
def _fit(self, *args, **kwargs):
Expand Down Expand Up @@ -999,7 +998,6 @@ def predict(self, comparison_vectors):
# format and return the result
return self._return_result(prediction, comparison_vectors)

@abstractmethod
def _post_predict(self, result):
"""Method called after prediction.
Expand All @@ -1008,7 +1006,7 @@ def _post_predict(self, result):
result : pandas.Series
The resulting classification.
"""
pass
return

@abstractmethod
def _prob_match(self, *args, **kwargs):
Expand Down
6 changes: 3 additions & 3 deletions recordlinkage/classifiers.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,14 +415,14 @@ def _predict(self, features):
self.kernel.classes_ = numpy.array([0, 1])

if not fit_bool:
raise NotFittedError
raise NotFittedError()

prediction = self.kernel.predict(features)
except NotFittedError as err:
raise NotFittedError from err(
raise NotFittedError(
"{} is not fitted yet. Call 'fit' with appropriate "
"arguments before using this method.".format(type(self).__name__)
)
) from err

return prediction

Expand Down

0 comments on commit a3c2298

Please sign in to comment.