-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
add a test for loc method; check if a warning raise when replacing a … #36486
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
Hello @samilAyoub! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found: There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻 Comment last updated at 2020-09-22 11:20:12 UTC |
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 @samilAyoub for the PR!
some comments, o/w lgtm
pandas/tests/indexing/test_loc.py
Outdated
df2 = df1.copy() | ||
df2[:] = np.nan | ||
# it fail if a warning is not raised | ||
with pytest.warns(Warning): |
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.
we use tm.assert_produces_warning
instead of pytest.warns
Line 2539 in d38dc06
def assert_produces_warning( |
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.
Done
pandas/tests/indexing/test_loc.py
Outdated
@@ -1130,3 +1130,16 @@ def test_loc_with_period_index_indexer(): | |||
tm.assert_frame_equal(df, df.loc[list(idx)]) | |||
tm.assert_frame_equal(df.iloc[0:5], df.loc[idx[0:5]]) | |||
tm.assert_frame_equal(df, df.loc[list(idx)]) | |||
|
|||
def test_loc_replace_subset_with_another(): |
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.
I'd call it test_loc_replace_subset_with_subset
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.
Done
@arw2019 I need a help here, why Linting step fail here? |
So I don't think this is actually testable with the current setup. Apparently code run in tests is configured to raise an error instead of a warning on chained assignment (hence all the test failures): Line 151 in d38dc06
|
@dsaxton So we can modify the test to capture raising instead of warning when chained assignment is used. |
That seems reasonable |
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.
One tiny nitpick, otherwise looks good (CI failures are unrelated)
Also if you can now merge master that should fix the CI |
Co-authored-by: Daniel Saxton <[email protected]>
@dsaxton did you mean merging master branch into this branch (add_test_subframe)? |
Yes, actually it seems CI is fine so not really necessary |
@dsaxton Thank you for your review ! |
pandas/tests/indexing/test_loc.py
Outdated
@@ -1130,3 +1131,17 @@ def test_loc_with_period_index_indexer(): | |||
tm.assert_frame_equal(df, df.loc[list(idx)]) | |||
tm.assert_frame_equal(df.iloc[0:5], df.loc[idx[0:5]]) | |||
tm.assert_frame_equal(df, df.loc[list(idx)]) | |||
|
|||
|
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.
can you put in pandas/tests/indexing/test_chaining_and_caching.py instead with the rest of these tests
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.
sure
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.
There is already a function called test_detect_chained_assignment_warnings
that test if chained assignment raise a warning SettingWithCopyWarning
in the case of warn option. We need just modify that function to detect also SettingWithCopyError
in the case of raise option.
thanks @samilAyoub |
…subframe
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff