Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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
@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:

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