Skip to content

Commit

Permalink
FIX Fixes common test for requires_positive_X (scikit-learn#24667)
Browse files Browse the repository at this point in the history
Co-authored-by: Guillaume Lemaitre <g.lemaitre58@gmail.com>
  • Loading branch information
2 people authored and andportnoy committed Nov 5, 2022
1 parent 7cd9fd9 commit 54b3c6d
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 102 deletions.
3 changes: 3 additions & 0 deletions doc/whats_new/v1.2.rst
Expand Up @@ -581,6 +581,9 @@ Changelog
in version 1.4.
:pr:`23834` by :user:`Meekail Zain <micky774>`

- |FIX| :func:`utils.estimator_checks.check_estimator` now takes into account
the `requires_positive_X` tag correctly. :pr:`24667` by `Thomas Fan`_.

Code and Documentation Contributors
-----------------------------------

Expand Down
4 changes: 2 additions & 2 deletions sklearn/tests/test_docstring_parameters.py
Expand Up @@ -18,7 +18,7 @@
from sklearn.utils._testing import ignore_warnings
from sklearn.utils import all_estimators
from sklearn.utils.estimator_checks import _enforce_estimator_tags_y
from sklearn.utils.estimator_checks import _enforce_estimator_tags_x
from sklearn.utils.estimator_checks import _enforce_estimator_tags_X
from sklearn.utils.estimator_checks import _construct_instance
from sklearn.utils.fixes import sp_version, parse_version
from sklearn.utils.deprecation import _is_deprecated
Expand Down Expand Up @@ -300,7 +300,7 @@ def test_fit_docstring_attributes(name, Estimator):
)

y = _enforce_estimator_tags_y(est, y)
X = _enforce_estimator_tags_x(est, X)
X = _enforce_estimator_tags_X(est, X)

if "1dlabels" in est._get_tags()["X_types"]:
est.fit(y)
Expand Down
4 changes: 2 additions & 2 deletions sklearn/tests/test_metaestimators.py
Expand Up @@ -9,7 +9,7 @@
from sklearn.base import is_regressor
from sklearn.datasets import make_classification
from sklearn.utils import all_estimators
from sklearn.utils.estimator_checks import _enforce_estimator_tags_x
from sklearn.utils.estimator_checks import _enforce_estimator_tags_X
from sklearn.utils.estimator_checks import _enforce_estimator_tags_y
from sklearn.utils.validation import check_is_fitted
from sklearn.utils._testing import set_random_state
Expand Down Expand Up @@ -289,7 +289,7 @@ def test_meta_estimators_delegate_data_validation(estimator):
y = rng.randint(3, size=n_samples)

# We convert to lists to make sure it works on array-like
X = _enforce_estimator_tags_x(estimator, X).tolist()
X = _enforce_estimator_tags_X(estimator, X).tolist()
y = _enforce_estimator_tags_y(estimator, y).tolist()

# Calling fit should not raise any data validation exception since X is a
Expand Down

0 comments on commit 54b3c6d

Please sign in to comment.