-
-
Notifications
You must be signed in to change notification settings - Fork 26.5k
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
| 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.
betatim
left a comment
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).
glemaitre
left a comment
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 <[email protected]>
Co-authored-by: Guillaume Lemaitre <[email protected]>
Reference Issues/PRs
Fixes #24659
What does this implement/fix? Explain your changes.
This PR fixes the common tests to pass when
requires_positive_XisTrue. Updates include:_enforce_estimator_tags_xto_enforce_estimator_tags_X_pairwise_estimator_convert_Xinto_enforce_estimator_tags_xso there is a single entry point to "adjust X".SkewedChi2Samplerwithskewedness=1.0is a strange case where it accepts negative values infitbut not intransform. This estimator is special cased in_enforce_estimator_tags_X.