def test_decorate_validated_function():
    """Check that validate_params functions can be decorated"""
    decorated_function = deprecated()(_func)

    with pytest.warns(FutureWarning, match="Function _func is deprecated"):
        decorated_function(1, 2, c=3)

    # outer decorator does not interfer with validation
    with pytest.warns(FutureWarning, match="Function _func is deprecated"):
        with pytest.raises(ValueError,
                           match=r"The 'c' parameter of _func must be"):
            decorated_function(1, 2, c="wrong")
Beispiel #2
0
    WindowsError = None

import sklearn
from sklearn.base import BaseEstimator
from sklearn.externals import joblib
from sklearn.utils.fixes import signature
from sklearn.utils import deprecated

additional_names_in_all = []
try:
    from nose.tools import raises as _nose_raises
    deprecation_message = (
        'sklearn.utils.testing.raises has been deprecated in version 0.20 '
        'and will be removed in 0.22. Please use '
        'sklearn.utils.testing.assert_raises instead.')
    raises = deprecated(deprecation_message)(_nose_raises)
    additional_names_in_all.append('raises')
except ImportError:
    pass

try:
    from nose.tools import with_setup as _with_setup
    deprecation_message = (
        'sklearn.utils.testing.with_setup has been deprecated in version 0.20 '
        'and will be removed in 0.22.'
        'If your code relies on with_setup, please use'
        ' nose.tools.with_setup instead.')
    with_setup = deprecated(deprecation_message)(_with_setup)
    additional_names_in_all.append('with_setup')
except ImportError:
    pass
Beispiel #3
0
import sklearn
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

additional_names_in_all = []
try:
    from nose.tools import raises as _nose_raises
    deprecation_message = (
        'sklearn.utils.testing.raises has been deprecated in version 0.20 '
        'and will be removed in 0.22. Please use '
        'sklearn.utils.testing.assert_raises instead.')
    raises = deprecated(deprecation_message)(_nose_raises)
    additional_names_in_all.append('raises')
except ImportError:
    pass

try:
    from nose.tools import with_setup as _with_setup
    deprecation_message = (
        'sklearn.utils.testing.with_setup has been deprecated in version 0.20 '
        'and will be removed in 0.22.'
        'If your code relies on with_setup, please use'
        ' nose.tools.with_setup instead.')
    with_setup = deprecated(deprecation_message)(_with_setup)
    additional_names_in_all.append('with_setup')
except ImportError:
    pass
Beispiel #4
0
from sklearn.utils import deprecated, IS_PYPY, _IS_32BIT

__all__ = [
    "assert_equal", "assert_not_equal", "assert_raises",
    "assert_raises_regexp", "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", "assert_allclose", "assert_run_python_script",
    "SkipTest", "all_estimators"
]

_dummy = TestCase('__init__')
deprecation_message = (
    'This helper is deprecated in version 0.22 and will be removed in version '
    '0.24. Please use "assert" instead')
assert_equal = deprecated(deprecation_message)(_dummy.assertEqual)
assert_not_equal = deprecated(deprecation_message)(_dummy.assertNotEqual)
assert_raises = _dummy.assertRaises
SkipTest = unittest.case.SkipTest
assert_dict_equal = _dummy.assertDictEqual
assert_in = deprecated(deprecation_message)(_dummy.assertIn)
assert_not_in = deprecated(deprecation_message)(_dummy.assertNotIn)
assert_less = deprecated(deprecation_message)(_dummy.assertLess)
assert_greater = deprecated(deprecation_message)(_dummy.assertGreater)
assert_less_equal = deprecated(deprecation_message)(_dummy.assertLessEqual)
assert_greater_equal = deprecated(deprecation_message)(
    _dummy.assertGreaterEqual)

assert_raises_regex = _dummy.assertRaisesRegex
# assert_raises_regexp is deprecated in Python 3.4 in favor of
# assert_raises_regex but lets keep the backward compat in scikit-learn with
Beispiel #5
0
import sklearn
from sklearn.base import BaseEstimator
from sklearn.externals import joblib
from sklearn.utils.fixes import signature
from sklearn.utils import deprecated, IS_PYPY


additional_names_in_all = []
try:
    from nose.tools import raises as _nose_raises
    deprecation_message = (
        'sklearn.utils.testing.raises has been deprecated in version 0.20 '
        'and will be removed in 0.22. Please use '
        'sklearn.utils.testing.assert_raises instead.')
    raises = deprecated(deprecation_message)(_nose_raises)
    additional_names_in_all.append('raises')
except ImportError:
    pass

try:
    from nose.tools import with_setup as _with_setup
    deprecation_message = (
        'sklearn.utils.testing.with_setup has been deprecated in version 0.20 '
        'and will be removed in 0.22.'
        'If your code relies on with_setup, please use'
        ' nose.tools.with_setup instead.')
    with_setup = deprecated(deprecation_message)(_with_setup)
    additional_names_in_all.append('with_setup')
except ImportError:
    pass

@deprecated(
    'The load_template class is deprecated and will be removed in a future version of chainladder. Use xlcompose library directly for the same functionality'
)
def load_template(template, env=None, **kwargs):
    path = os.path.dirname(os.path.abspath(__file__))
    try:
        return load_yaml(template, env, **kwargs)
    except:
        template = os.path.join(path, "templates", template.lower() + ".yaml")
        return load_yaml(template, env, **kwargs)


DatFrame = deprecated(
    'The DataFrame class is deprecated and will be removed in a future version of chainladder. Use xlcompose library directly for the same functionality'
)(DataFrame)
Series = deprecated(
    'The Series class is deprecated and will be removed in a future version of chainladder. Use xlcompose library directly for the same functionality'
)(Series)
Row = deprecated(
    'The Row class is deprecated and will be removed in a future version of chainladder. Use xlcompose library directly for the same functionality'
)(Row)
Column = deprecated(
    'The Column class is deprecated and will be removed in a future version of chainladder. Use xlcompose library directly for the same functionality'
)(Column)
Tabs = deprecated(
    'The Tabs class is deprecated and will be removed in a future version of chainladder. Use xlcompose library directly for the same functionality'
)(Tabs)
CSpacer = deprecated(
    'The CSpacer class is deprecated and will be removed in a future version of chainladder. Use xlcompose library directly for the same functionality'
Beispiel #7
0
assert_not_in = _dummy.assertNotIn
assert_less = _dummy.assertLess
assert_greater = _dummy.assertGreater
assert_less_equal = _dummy.assertLessEqual
assert_greater_equal = _dummy.assertGreaterEqual

assert_raises_regex = _dummy.assertRaisesRegex
# assert_raises_regexp is deprecated in Python 3.4 in favor of
# assert_raises_regex but lets keep the backward compat in scikit-learn with
# the old name for now
assert_raises_regexp = assert_raises_regex

deprecation_message = "'assert_true' is deprecated in version 0.21 " \
                      "and will be removed in version 0.23. " \
                      "Please use 'assert' instead."
assert_true = deprecated(deprecation_message)(_dummy.assertTrue)

deprecation_message = "'assert_false' is deprecated in version 0.21 " \
                      "and will be removed in version 0.23. " \
                      "Please use 'assert' instead."
assert_false = deprecated(deprecation_message)(_dummy.assertFalse)


def assert_warns(warning_class, func, *args, **kw):
    """Test that a certain warning occurs.

    Parameters
    ----------
    warning_class : the warning class
        The class to test for, e.g. UserWarning.
Beispiel #8
0
    WindowsError
except NameError:
    WindowsError = None

import sklearn
from sklearn.base import BaseEstimator
from sklearn.externals import joblib
from sklearn.utils import deprecated

try:
    from nose.tools import raises as _nose_raises
    deprecation_message = (
        'sklearn.utils.testing.raises has been deprecated in version 0.20 '
        'and will be removed in 0.22. Please use '
        'sklearn.utils.testing.assert_raises instead.')
    raises = deprecated(deprecation_message)(_nose_raises)
except ImportError:
    pass
from nose import with_setup

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
Beispiel #9
0
import sklearn
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

additional_names_in_all = []
try:
    from nose.tools import raises as _nose_raises
    deprecation_message = (
        'sklearn.utils.testing.raises has been deprecated in version 0.20 '
        'and will be removed in 0.22. Please use '
        'sklearn.utils.testing.assert_raises instead.')
    raises = deprecated(deprecation_message)(_nose_raises)
    additional_names_in_all.append('raises')
except ImportError:
    pass

try:
    from nose.tools import with_setup as _with_setup
    deprecation_message = (
        'sklearn.utils.testing.with_setup has been deprecated in version 0.20 '
        'and will be removed in 0.22.'
        'If your code relies on with_setup, please use'
        ' nose.tools.with_setup instead.')
    with_setup = deprecated(deprecation_message)(_with_setup)
    additional_names_in_all.append('with_setup')
except ImportError:
    pass