Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

TST Change assert from sklearn to pytest style in tests/test_discriminant.py #19558

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
Mar 2, 2021

Conversation

azihna
Copy link
Contributor

@azihna azihna commented Feb 25, 2021

Reference Issues/PRs
Reference #14216

What does this implement/fix? Explain your changes.

Changed the assert_raises, assert_message, assert_warns in tests/test_discriminant.py to pytest.raises() and pytest.warns.
Changed ignore_warnings to @pytest.mark.filterwarnings() because each assert in the test was encapsulated in ignore_warnings context.

@azihna azihna changed the title Change assert from sklearn to pytest style TST Change assert from sklearn to pytest style Feb 25, 2021
@ogrisel ogrisel added No Changelog Needed module:test-suite everything related to our tests labels Feb 25, 2021
sklearn/tests/test_discriminant_analysis.py Outdated Show resolved Hide resolved
@ogrisel ogrisel changed the title TST Change assert from sklearn to pytest style TST Change assert from sklearn to pytest style in in tests/test_discriminant.py Feb 25, 2021
@ogrisel
Copy link
Member

ogrisel commented Feb 25, 2021

Note: I edited the title to make it more explicit about which module is impacted when scanning though the discussion history of #14216.

@azihna azihna changed the title TST Change assert from sklearn to pytest style in in tests/test_discriminant.py TST Change assert from sklearn to pytest style in tests/test_discriminant.py Feb 25, 2021
Copy link
Member

@ogrisel ogrisel left a comment

Choose a reason for hiding this comment

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

Thanks, it's better. I think we could make the test even clearer by checking the messages:

sklearn/tests/test_discriminant_analysis.py Outdated Show resolved Hide resolved
sklearn/tests/test_discriminant_analysis.py Outdated Show resolved Hide resolved
sklearn/tests/test_discriminant_analysis.py Outdated Show resolved Hide resolved
sklearn/tests/test_discriminant_analysis.py Outdated Show resolved Hide resolved
sklearn/tests/test_discriminant_analysis.py Outdated Show resolved Hide resolved
Copy link
Member

@ogrisel ogrisel left a comment

Choose a reason for hiding this comment

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

Ok I investigated #19558 (review) and found that the runtime warning (divide by zero) was always raised at predict time only (for the unregularized case) while the fit method only raises the UserWarning.

I reorganized the checks accordingly.

I think this highlights suboptimal warning behavior of this class. I will open a dedicated issue. Fixing this can be done in a subsequent PR to keep the scope of this PR focused on the original problem.

@azihna
Copy link
Contributor Author

azihna commented Mar 1, 2021

Thanks @ogrisel

Copy link
Member

@rth rth left a comment

Choose a reason for hiding this comment

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

Thanks @azihna and @ogrisel !

@rth rth merged commit 28ee486 into scikit-learn:main Mar 2, 2021
@glemaitre glemaitre mentioned this pull request Apr 22, 2021
12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module:test-suite everything related to our tests No Changelog Needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.