Skip to content

TST replace assert_raises* by pytest.raises in model_selection/tests/test_split.py #19375

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

Conversation

cycks
Copy link
Contributor

@cycks cycks commented Feb 6, 2021

Reference Issues/PRs

References #14216

What does this implement/fix? Explain your changes.

Removes the use of assert_raises* in model_selection/tests/test_split.py

Any other comments?

cc: (pair programming partner) @mohaseeb

@cycks
Copy link
Contributor Author

cycks commented Feb 6, 2021

#DataUmbrella sprint

@glemaitre
Copy link
Member

@cycks
Copy link
Contributor Author

cycks commented Feb 6, 2021

of course

@cycks cycks force-pushed the remove_use_of_assert_raises_from_test_split branch from fb1d8cb to bf95d03 Compare February 6, 2021 11:29
Copy link
Member

@lorentzenchr lorentzenchr left a comment

Choose a reason for hiding this comment

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

Could you also replace assert_raise_messagewith pytest-raises?

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.

LGTM overall. +1 for merging this with or without @lorentzenchr's comment above and the following style nitpicks.

Comment on lines +1391 to +1395
with pytest.raises(
ValueError,
match="Cannot have number of splits.*greater"
):
next(GroupKFold(n_splits=3).split(X, y, groups))
Copy link
Member

Choose a reason for hiding this comment

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

nitpick, I think the future indenting style we are converging to for the scikit-learn project for such multiline expressions would rather be the following (@glemaitre correct me if I am wrong):

Suggested change
with pytest.raises(
ValueError,
match="Cannot have number of splits.*greater"
):
next(GroupKFold(n_splits=3).split(X, y, groups))
with pytest.raises(
ValueError,
match="Cannot have number of splits.*greater"
):
next(GroupKFold(n_splits=3).split(X, y, groups))

Copy link
Member

Choose a reason for hiding this comment

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

It looks correct :)

with pytest.raises(
ValueError,
match="Cannot have number of folds.*greater"
):
Copy link
Member

Choose a reason for hiding this comment

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

similar comment here.

@cycks
Copy link
Contributor Author

cycks commented Feb 6, 2021

assert_raise_message

Sure

@glemaitre
Copy link
Member

I would be in favour of the assert_raise_message to be in line with the other PRs as well.

Comment on lines +1402 to +1405
with pytest.raises(
ValueError,
match="Cannot have number of folds.*greater"
):
Copy link
Member

Choose a reason for hiding this comment

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

FYI

Suggested change
with pytest.raises(
ValueError,
match="Cannot have number of folds.*greater"
):
with pytest.raises(
ValueError,
match="Cannot have number of folds.*greater"
):

@glemaitre glemaitre changed the title replace assert_raises* by pytest.raise in model_selection/tests/test_split.py TST replace assert_raises* by pytest.raises in model_selection/tests/test_split.py Feb 7, 2021
@reshamas
Copy link
Member

Hello @cycks @mohaseeb
How is this PR going? Do you have any questions we can help with?

@mohaseeb
Copy link
Contributor

mohaseeb commented Mar 1, 2021

I'll continue working on this PR.

@mohaseeb
Copy link
Contributor

mohaseeb commented Mar 1, 2021

Due to lack of permissions to push to this PR branch, a new branch starting from this PR branch is created. #19585 is a new PR with fixes to the comments raised here.

@rth
Copy link
Member

rth commented Mar 2, 2021

Resolved in #19585 . Thanks!

@rth rth closed this Mar 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants