|
11 | 11 | import six |
12 | 12 | from ._util import ArrayIndexer, check_input, validate_vector |
13 | 13 | import warnings |
14 | | -import sys |
15 | 14 |
|
16 | 15 |
|
17 | 16 | class BaseMetricLearner(six.with_metaclass(ABCMeta, BaseEstimator)): |
@@ -241,22 +240,14 @@ def transform(self, X): |
241 | 240 | X_embedded : `numpy.ndarray`, shape=(n_samples, n_components) |
242 | 241 | The embedded data points. |
243 | 242 | """ |
244 | | - # TODO: remove when we stop supporting Python < 3.5 |
245 | | - if sys.version_info.major < 3 or sys.version_info.minor < 5: |
246 | | - check_is_fitted(self, ['preprocessor_', 'components_']) |
247 | | - else: |
248 | | - check_is_fitted(self) |
| 243 | + check_is_fitted(self, ['preprocessor_', 'components_']) |
249 | 244 | X_checked = check_input(X, type_of_inputs='classic', estimator=self, |
250 | 245 | preprocessor=self.preprocessor_, |
251 | 246 | accept_sparse=True) |
252 | 247 | return X_checked.dot(self.components_.T) |
253 | 248 |
|
254 | 249 | def get_metric(self): |
255 | | - # TODO: remove when we stop supporting Python < 3.5 |
256 | | - if sys.version_info.major < 3 or sys.version_info.minor < 5: |
257 | | - check_is_fitted(self, 'components_') |
258 | | - else: |
259 | | - check_is_fitted(self) |
| 250 | + check_is_fitted(self, 'components_') |
260 | 251 | components_T = self.components_.T.copy() |
261 | 252 |
|
262 | 253 | def metric_fun(u, v, squared=False): |
@@ -309,11 +300,7 @@ def get_mahalanobis_matrix(self): |
309 | 300 | M : `numpy.ndarray`, shape=(n_features, n_features) |
310 | 301 | The copy of the learned Mahalanobis matrix. |
311 | 302 | """ |
312 | | - # TODO: remove when we stop supporting Python < 3.5 |
313 | | - if sys.version_info.major < 3 or sys.version_info.minor < 5: |
314 | | - check_is_fitted(self, 'components_') |
315 | | - else: |
316 | | - check_is_fitted(self) |
| 303 | + check_is_fitted(self, 'components_') |
317 | 304 | return self.components_.T.dot(self.components_) |
318 | 305 |
|
319 | 306 |
|
@@ -376,11 +363,7 @@ def decision_function(self, pairs): |
376 | 363 | y_predicted : `numpy.ndarray` of floats, shape=(n_constraints,) |
377 | 364 | The predicted decision function value for each pair. |
378 | 365 | """ |
379 | | - # TODO: remove when we stop supporting Python < 3.5 |
380 | | - if sys.version_info.major < 3 or sys.version_info.minor < 5: |
381 | | - check_is_fitted(self, 'preprocessor_') |
382 | | - else: |
383 | | - check_is_fitted(self) |
| 366 | + check_is_fitted(self, 'preprocessor_') |
384 | 367 | pairs = check_input(pairs, type_of_inputs='tuples', |
385 | 368 | preprocessor=self.preprocessor_, |
386 | 369 | estimator=self, tuple_size=self._tuple_size) |
@@ -623,11 +606,7 @@ def predict(self, quadruplets): |
623 | 606 | prediction : `numpy.ndarray` of floats, shape=(n_constraints,) |
624 | 607 | Predictions of the ordering of pairs, for each quadruplet. |
625 | 608 | """ |
626 | | - # TODO: remove when we stop supporting Python < 3.5 |
627 | | - if sys.version_info.major < 3 or sys.version_info.minor < 5: |
628 | | - check_is_fitted(self, 'preprocessor_') |
629 | | - else: |
630 | | - check_is_fitted(self) |
| 609 | + check_is_fitted(self, 'preprocessor_') |
631 | 610 | quadruplets = check_input(quadruplets, type_of_inputs='tuples', |
632 | 611 | preprocessor=self.preprocessor_, |
633 | 612 | estimator=self, tuple_size=self._tuple_size) |
@@ -656,11 +635,7 @@ def decision_function(self, quadruplets): |
656 | 635 | decision_function : `numpy.ndarray` of floats, shape=(n_constraints,) |
657 | 636 | Metric differences. |
658 | 637 | """ |
659 | | - # TODO: remove when we stop supporting Python < 3.5 |
660 | | - if sys.version_info.major < 3 or sys.version_info.minor < 5: |
661 | | - check_is_fitted(self, 'preprocessor_') |
662 | | - else: |
663 | | - check_is_fitted(self) |
| 638 | + check_is_fitted(self, 'preprocessor_') |
664 | 639 | quadruplets = check_input(quadruplets, type_of_inputs='tuples', |
665 | 640 | preprocessor=self.preprocessor_, |
666 | 641 | estimator=self, tuple_size=self._tuple_size) |
|
0 commit comments