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
[MRG]Replaced all occurrences of assert_true() and assert_false() with assert. #12588
Conversation
…ert and assert not, kept definitions of replaced functions. Tested with pytest, flake8 and by using make.
Flake8 is not happy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this!
A few comments are below. Generally a few remarks (I have not commented in all the places where these apply),
- in
assert not(result)
, parentheses are not needed, useassert not result
. - For line breaks in
assert
, see https://stackoverflow.com/a/16065512/1791279
I find it OK (for lack of better alternatives) to use line break for a single line, e.g.however, when you get more than one line, use parentheses,assert result, \ "some long error message"
assert result, ( "some long error message: {}" "another line" .format(custom_message))
Thanks for feedback! I'll clean this up today. |
@jaskola8 any updates? |
…embership cleanup) for first half of tests (including models_selection/tests/test_validation.py).
@jaskola8 Why WIP? You don't need to worry about the first job of Travis now. ping when it's ready for a second review. |
I wasn't sure how to indicate that this branch is not ready for merge so i changed [MRG] to [WIP]. If integration tests running now will be successful i will change it to [MRG]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for this work @jaskola8 !
A few minor comments below, but apart from that this LGTM.
'MockClassifier extra fit_param ' | ||
'sample_weight.shape[0]' | ||
' is {0}, should be {1}'.format(sample_weight.shape[0], | ||
X.shape[0])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit (only if you do changes for other reviewers), this could be more nicely written as,
'sample_weight.shape[0] is {0}, should be {1}'
.format(sample_weight.shape[0], X.shape[0]))
sklearn/svm/tests/test_bounds.py
Outdated
@@ -61,8 +61,8 @@ def check_l1_min_c(X, y, loss, fit_intercept=True, intercept_scaling=None): | |||
|
|||
clf.C = min_c * 1.01 | |||
clf.fit(X, y) | |||
assert_true((np.asarray(clf.coef_) != 0).any() or | |||
(np.asarray(clf.intercept_) != 0).any()) | |||
assert (np.asarray(clf.coef_) != 0).any() or \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better to use the parenthesis here I think,
assert ((np.asarray(clf.coef_) != 0).any() or
(np.asarray(clf.intercept_) != 0).any())
hasattr(MetaEstTestList(HasPredict(), HasPredict()), 'predict')) | ||
assert not hasattr(MetaEst(HasNoPredict()), 'predict') | ||
assert not \ | ||
hasattr(MetaEstTestTuple(HasNoPredict(), HasNoPredict()), 'predict') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also,
assert not hasattr(MetaEstTestTuple(HasNoPredict(), HasNoPredict()),
'predict')
or something similar if this is too long.
assert hasattr(MetaEstTestTuple(HasPredict(), HasNoPredict()), 'predict') | ||
assert not \ | ||
hasattr(MetaEstTestTuple(HasNoPredict(), HasPredict()), 'predict') | ||
assert not \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above
X.dtype == X_checked.dtype and | ||
X_checked.flags['C_CONTIGUOUS'] == X.flags['C_CONTIGUOUS'] and | ||
X_checked.flags['F_CONTIGUOUS'] == X.flags['F_CONTIGUOUS'] | ||
): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an unrelated change I think? I'm not convinced the new formatting is much better, better to revert this.
Thank you for your feedback, should I apply changes you mentioned above or leave it as it is? |
The first one was optionally, but if you could fix the other ones it would be great. Thanks again for contributing! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @jaskola8
…with assert (scikit-learn#12588)" This reverts commit 13da08b.
…with assert (scikit-learn#12588)" This reverts commit 13da08b.
Reference Issues/PRs
#12580
What does this implement/fix? Explain your changes.
Replaced all occurrences of assert_true() and assert_false() with assert, kept definitions of replaced functions in sklearn.utils.testing.
Any other comments?
Tested with pytest, flake8 and by using make.