Skip to content

Commit

Permalink
MNT Minor code refactoring in utils.testing (#12688)
Browse files Browse the repository at this point in the history
  • Loading branch information
qinhanmin2014 authored and amueller committed Dec 17, 2018
1 parent 4822a19 commit dc5359f
Showing 1 changed file with 13 additions and 20 deletions.
33 changes: 13 additions & 20 deletions sklearn/utils/testing.py
Expand Up @@ -42,12 +42,21 @@
except NameError:
WindowsError = None

from numpy.testing import assert_allclose
from numpy.testing import assert_almost_equal
from numpy.testing import assert_approx_equal
from numpy.testing import assert_array_equal
from numpy.testing import assert_array_almost_equal
from numpy.testing import assert_array_less
import numpy as np

import sklearn
from sklearn.base import BaseEstimator
from sklearn.base import (BaseEstimator, ClassifierMixin, ClusterMixin,
RegressorMixin, TransformerMixin)
from sklearn.utils import deprecated, IS_PYPY, _IS_32BIT
from sklearn.utils._joblib import joblib
from sklearn.utils._unittest_backport import TestCase
from sklearn.utils.fixes import signature
from sklearn.utils import deprecated, IS_PYPY, _IS_32BIT


additional_names_in_all = []
try:
Expand All @@ -73,24 +82,13 @@
except ImportError:
pass

from numpy.testing import assert_almost_equal
from numpy.testing import assert_array_equal
from numpy.testing import assert_array_almost_equal
from numpy.testing import assert_array_less
from numpy.testing import assert_approx_equal
import numpy as np

from sklearn.base import (ClassifierMixin, RegressorMixin, TransformerMixin,
ClusterMixin)
from sklearn.utils._unittest_backport import TestCase

__all__ = ["assert_equal", "assert_not_equal", "assert_raises",
"assert_raises_regexp", "assert_true",
"assert_false", "assert_almost_equal", "assert_array_equal",
"assert_array_almost_equal", "assert_array_less",
"assert_less", "assert_less_equal",
"assert_greater", "assert_greater_equal",
"assert_approx_equal", "SkipTest"]
"assert_approx_equal", "assert_allclose", "SkipTest"]
__all__.extend(additional_names_in_all)

_dummy = TestCase('__init__')
Expand Down Expand Up @@ -379,11 +377,6 @@ def __exit__(self, *exc_info):
clean_warning_registry()


assert_less = _dummy.assertLess
assert_greater = _dummy.assertGreater

assert_allclose = np.testing.assert_allclose

def assert_raise_message(exceptions, message, function, *args, **kwargs):
"""Helper function to test the message raised in an exception.
Expand Down

0 comments on commit dc5359f

Please sign in to comment.