10000 MNT Minor code refactoring in utils.testing (#12688) · scikit-learn/scikit-learn@ccf0d92 · GitHub
[go: up one dir, main page]

Skip to content

Commit ccf0d92

Browse files
MNT Minor code refactoring in utils.testing (#12688)
1 parent bfa3aaa commit ccf0d92

File tree

1 file changed

+13
-20
lines changed

1 file changed

+13
-20
lines changed

sklearn/utils/testing.py

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,21 @@
4242
except NameError:
4343
WindowsError = None
4444

45+
from numpy.testing import assert_allclose
46+
from numpy.testing import assert_almost_equal
47+
from numpy.testing import assert_approx_equal
48+
from numpy.testing import assert_array_equal
49+
from numpy.testing import assert_array_almost_equal
50+
from numpy.testing import assert_array_less
51+
import numpy as np
52+
4553
import sklearn
46-
from sklearn.base import BaseEstimator
54+
from sklearn.base import (BaseEstimator, ClassifierMixin, ClusterMixin,
55+
RegressorMixin, TransformerMixin)
56+
from sklearn.utils import deprecated, IS_PYPY, _IS_32BIT
4757
from sklearn.utils._joblib import joblib
58+
from sklearn.utils._unittest_backport import TestCase
4859
from sklearn.utils.fixes import signature
49-
from sklearn.utils import deprecated, IS_PYPY, _IS_32BIT
50-
5160

5261
additional_names_in_all = []
5362
try:
@@ -73,24 +82,13 @@
7382
except ImportError:
7483
pass
7584

76-
from numpy.testing import assert_almost_equal
77-
from numpy.testing import assert_array_equal
78-
from numpy.testing import assert_array_almost_equal
79-
from numpy.testing import assert_array_less
80-
from numpy.testing import assert_approx_equal
81-
import numpy as np
82-
83-
from sklearn.base import (ClassifierMixin, RegressorMixin, TransformerMixin,
84-
ClusterMixin)
85-
from sklearn.utils._unittest_backport import TestCase
86-
8785
__all__ = ["assert_equal", "assert_not_equal", "assert_raises",
8886
"assert_raises_regexp", "assert_true",
8987
"assert_false", "assert_almost_equal", "assert_array_equal",
9088
"assert_array_almost_equal", "assert_array_less",
9189
"assert_less", "assert_less_equal",
9290
"assert_greater", "assert_greater_equal",
93-
"assert_approx_equal", "SkipTest"]
91+
"assert_approx_equal", "assert_allclose", "SkipTest"]
9492
__all__.extend(additional_names_in_all)
9593

9694
_dummy = TestCase('__init__')
@@ -379,11 +377,6 @@ def __exit__(self, *exc_info):
379377
clean_warning_registry()
380378

381379

382-
assert_less = _dummy.assertLess
383-
assert_greater = _dummy.assertGreater
384-
385-
assert_allclose = np.testing.assert_allclose
386-
387380
def assert_raise_message(exceptions, message, function, *args, **kwargs):
388381
"""Helper function to test the message raised in an exception.
389382

0 commit comments

Comments
 (0)
0