forked from scikit-learn/scikit-learn
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ENH remove _xfail_checks, pass directly to check runners, return stru…
…ctured output from check_estimator (scikit-learn#30149)
- Loading branch information
1 parent
a71860a
commit 9012b78
Showing
43 changed files
with
1,025 additions
and
571 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
doc/whats_new/upcoming_changes/sklearn.utils/30149.enhancement.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
- Changes to :func:`~utils.estimator_checks.check_estimator` and | ||
:func:`~utils.estimator_checks.parametrize_with_checks`. | ||
|
||
- :func:`~utils.estimator_checks.check_estimator` introduces new arguments: | ||
``on_skip``, ``on_fail``, and ``callback`` to control the behavior of the check | ||
runner. Refer to the API documentation for more details. | ||
|
||
- ``generate_only=True`` is deprecated in | ||
:func:`~utils.estimator_checks.check_estimator`. Use | ||
:func:`~utils.estimator_checks.estimator_checks_generator` instead. | ||
|
||
- The ``_xfail_checks`` estimator tag is now removed, and now in order to indicate | ||
which tests are expected to fail, you can pass a dictionary to the | ||
:func:`~utils.estimator_checks.check_estimator` as the ``expected_failed_checks`` | ||
parameter. Similarly, the ``expected_failed_checks`` parameter in | ||
:func:`~utils.estimator_checks.parametrize_with_checks` can be used, which is a | ||
callable returning a dictionary of the form:: | ||
|
||
{ | ||
"check_name": "reason to mark this check as xfail", | ||
} | ||
|
||
By `Adrin Jalali`_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# This script checks that the common tests marked with xfail are actually | ||
# failing. | ||
# Note that in some cases, a test might be marked with xfail because it is | ||
# failing on certain machines, and might not be triggered by this script. | ||
|
||
import contextlib | ||
import io | ||
|
||
from sklearn.utils._test_common.instance_generator import ( | ||
_get_expected_failed_checks, | ||
_tested_estimators, | ||
) | ||
from sklearn.utils.estimator_checks import check_estimator | ||
|
||
for estimator in _tested_estimators(): | ||
# calling check_estimator w/o passing expected_failed_checks will find | ||
# all the failing tests in your environment. | ||
# suppress stdout/stderr while running checks | ||
with ( | ||
contextlib.redirect_stdout(io.StringIO()), | ||
contextlib.redirect_stderr(io.StringIO()), | ||
): | ||
check_results = check_estimator(estimator, on_skip=None, on_fail=None) | ||
failed_tests = [e for e in check_results if e["status"] == "failed"] | ||
failed_test_names = set(e["check_name"] for e in failed_tests) | ||
expected_failed_tests = set(_get_expected_failed_checks(estimator).keys()) | ||
unexpected_failures = failed_test_names - expected_failed_tests | ||
if unexpected_failures: | ||
print(f"{estimator.__class__.__name__} failed with unexpected failures:") | ||
for failure in unexpected_failures: | ||
print(f" {failure}") | ||
|
||
expected_but_not_raised = expected_failed_tests - failed_test_names | ||
if expected_but_not_raised: | ||
print(f"{estimator.__class__.__name__} did not fail expected failures:") | ||
for failure in expected_but_not_raised: | ||
print(f" {failure}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.