-
-
Notifications
You must be signed in to change notification settings - Fork 25.8k
FIX Fixes common test for requires_positive_X #24667
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FIX Fixes common test for requires_positive_X #24667
Conversation
|
||
# Check regressor with requires_positive_X estimator tag | ||
msg = "negative X values not supported!" | ||
with raises(ValueError, match=msg): | ||
check_estimator(RequiresPositiveXRegressor()) | ||
check_estimator(RequiresPositiveXRegressor()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the non-regression test. check_estimator
should pass if the estimator requires positive X
.
sklearn/utils/estimator_checks.py
Outdated
X = _enforce_estimator_tags_x(estimator, X) | ||
X = _pairwise_estimator_convert_X(X, estimator) | ||
X = _enforce_estimator_tags_X(estimator, X) | ||
X = _enforce_estimator_tags_X(estimator, X) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Double double trouble? I think one line can be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks reasonable to me.
I like the "normalisation" of using an upper case X and that it fixes the bug. On the rest I don't have a strong opinion (+0).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks @thomasjpfan
I will merge |
Co-authored-by: Guillaume Lemaitre <g.lemaitre58@gmail.com>
Co-authored-by: Guillaume Lemaitre <g.lemaitre58@gmail.com>
Reference Issues/PRs
Fixes #24659
What does this implement/fix? Explain your changes.
This PR fixes the common tests to pass when
requires_positive_X
isTrue
. Updates include:_enforce_estimator_tags_x
to_enforce_estimator_tags_X
_pairwise_estimator_convert_X
into_enforce_estimator_tags_x
so there is a single entry point to "adjust X".SkewedChi2Sampler
withskewedness=1.0
is a strange case where it accepts negative values infit
but not intransform
. This estimator is special cased in_enforce_estimator_tags_X
.