Skip to content

TST add a few more tests to API checks #29832

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 5 commits into from
Sep 18, 2024

Conversation

adrinjalali
Copy link
Member

This adds a few more tests to our API checks.

I'm not 100% sure about these two though:

    yield partial(check_estimators_fit_returns_self, readonly_memmap=True)
    if tags.requires_fit:
        yield check_estimators_unfitted

WDYT @glemaitre @adam2392 ?

@adrinjalali adrinjalali added No Changelog Needed Developer API Third party developer API related labels Sep 11, 2024
Copy link

github-actions bot commented Sep 11, 2024

✔️ Linting Passed

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

Generated for commit: 8d4d8a0. Link to the linter CI: here

@glemaitre glemaitre self-requested a review September 11, 2024 09:10
@adrinjalali
Copy link
Member Author

Fail is bogus, need #29834 to fix the issues here.

yield check_estimator_repr
yield check_no_attributes_set_in_init
yield check_fit_score_takes_y
yield check_estimators_overwrite_params
yield check_dont_overwrite_parameters
yield check_estimators_fit_returns_self
yield partial(check_estimators_fit_returns_self, readonly_memmap=True)
Copy link
Member

Choose a reason for hiding this comment

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

By looking at #5481 and #4807, I think this is part of the API to be compatible with the joblib parallelization.

So we should most probably have a check with a specific name to reflect this instead of the current name.

Copy link
Member

Choose a reason for hiding this comment

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

Would something like a separate function be good _yield_joblib_compatability_checks or would that be confusing?

My impression upon skimming the code is that some of these checks ensure joblib compatability, but might also ensure some API compliance?

Copy link
Member Author

Choose a reason for hiding this comment

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

Right, since this has to do with parallelisation, it's certainly API since it's needed for our meta-estimators. Creating a separate test name for it.

yield check_estimator_repr
yield check_no_attributes_set_in_init
yield check_fit_score_takes_y
yield check_estimators_overwrite_params
yield check_dont_overwrite_parameters
yield check_estimators_fit_returns_self
yield partial(check_estimators_fit_returns_self, readonly_memmap=True)
Copy link
Member Author

Choose a reason for hiding this comment

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

Right, since this has to do with parallelisation, it's certainly API since it's needed for our meta-estimators. Creating a separate test name for it.

@@ -753,10 +753,6 @@ def test_check_estimator():
msg = "object has no attribute 'fit'"
with raises(AttributeError, match=msg):
check_estimator(BaseEstimator())
# check that fit does input validation
msg = "Did not raise"
Copy link
Member Author

Choose a reason for hiding this comment

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

now that we assert the right message, it became clear that this was already tested in another test and was redundant.

@adrinjalali
Copy link
Member Author

I think I've addressed questions and suggestions. Ready for another review.

Copy link
Member

@glemaitre glemaitre left a comment

Choose a reason for hiding this comment

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

LGTM

@adrinjalali
Copy link
Member Author

@OmarManzoor maybe?

Copy link
Contributor

@OmarManzoor OmarManzoor left a comment

Choose a reason for hiding this comment

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

LGTM.

@OmarManzoor OmarManzoor merged commit cc5372c into scikit-learn:main Sep 18, 2024
30 checks passed
@adrinjalali adrinjalali deleted the tests/more-api-tests branch September 18, 2024 13:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants