Skip to content

TST fix estimator checks when set_output is called on the instance #29869

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

Merged
merged 8 commits into from
Sep 23, 2024

Conversation

adrinjalali
Copy link
Member

Fixes #26842

This fixes the issues with transformers where set_output is called on them.

cc @glemaitre @Charlie-XIAO

@adrinjalali adrinjalali added the Developer API Third party developer API related label Sep 17, 2024
Copy link

github-actions bot commented Sep 17, 2024

✔️ Linting Passed

All linting checks passed. Your pull request is in excellent shape! ☀️

Generated for commit: 1cea22c. Link to the linter CI: here

@adrinjalali adrinjalali added this to the 1.6 milestone Sep 17, 2024
@parametrize_with_checks(
[
StandardScaler().set_output(transform="pandas"),
StandardScaler().set_output(transform="polars"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might need to have some skipif because polars or pandas are optional dependencies.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these lines don't fail if pandas/polars are not installed, and check_estimator also dosn't fail when they're not installed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Scratch that, it fails. I'll fix it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:P

Copy link
Contributor

@Charlie-XIAO Charlie-XIAO left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LGTM as long as the comment above is resolved :)



# Test that set_output doesn't make the tests to fail.
@parametrize_with_checks(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can not use parametrize_with_checks here because it depends on pytest. The simple fix is to move it to sklearn/tests/test_common.py.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kinda prefer to have test_common.py to have as least tests as possible, to reduce the difference between what we force on third party estimators and what we expect from our own.

So I refactored the test here.

@thomasjpfan thomasjpfan merged commit 13de540 into scikit-learn:main Sep 23, 2024
30 checks passed
@adrinjalali adrinjalali deleted the tests/set-output branch September 23, 2024 16:32
kbharat1210 pushed a commit to kbharat1210/scikit-learn that referenced this pull request Sep 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Developer API Third party developer API related module:utils
Projects
None yet
Development

Successfully merging this pull request may close these issues.

check_estimator fails when checked after doing set_output(transform='pandas') on the instance
4 participants