Skip to content

Commit

Permalink
Made sklearn test backwards-compatible with sklearn < 1.3 (#3285)
Browse files Browse the repository at this point in the history
  • Loading branch information
schlunma authored and Javier Vegas-Regidor committed Jan 14, 2024
1 parent 3876eb3 commit f9a1497
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -459,10 +459,18 @@ def _more_tags(self):
return {"allow_nan": True}


class MockBaseEstimator:
"""Estimator with ``_get_tags``."""

def _get_tags(self):
"""Return tags."""
return _DEFAULT_TAGS


@pytest.mark.parametrize(
'estimator,err_msg',
[
(BaseEstimator(), 'The key xxx is not defined in _get_tags'),
(MockBaseEstimator(), 'The key xxx is not defined in _get_tags'),
(NoTagsEstimator(), 'The key xxx is not defined in _DEFAULT_TAGS'),
],
)
Expand All @@ -480,9 +488,8 @@ def test_safe_tags_error(estimator, err_msg):
(NoTagsEstimator(), 'allow_nan', _DEFAULT_TAGS['allow_nan']),
(MoreTagsEstimator(), None, {**_DEFAULT_TAGS, **{'allow_nan': True}}),
(MoreTagsEstimator(), 'allow_nan', True),
(BaseEstimator(), None, _DEFAULT_TAGS),
(BaseEstimator(), 'allow_nan', _DEFAULT_TAGS['allow_nan']),
(BaseEstimator(), 'allow_nan', _DEFAULT_TAGS['allow_nan']),
(MockBaseEstimator(), None, _DEFAULT_TAGS),
(MockBaseEstimator(), 'allow_nan', _DEFAULT_TAGS['allow_nan']),
],
)
def test_safe_tags_no_get_tags(estimator, key, expected_results):
Expand Down

0 comments on commit f9a1497

Please sign in to comment.