Skip to content

Conversation

@samilAyoub
Copy link
Contributor

@samilAyoub samilAyoub commented Sep 19, 2020

…subframe

@pep8speaks
Copy link

pep8speaks commented Sep 19, 2020

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
Copy link
Contributor

@arw2019 arw2019 left a 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

df2 = df1.copy()
df2[:] = np.nan
# it fail if a warning is not raised
with pytest.warns(Warning):
Copy link
Contributor

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

def assert_produces_warning(

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

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():
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@samilAyoub
Copy link
Contributor Author

samilAyoub commented Sep 19, 2020

@arw2019 I need a help here, why Linting step fail here?

@dsaxton dsaxton added the Testing pandas testing functions or related to the test suite label Sep 20, 2020
@dsaxton
Copy link
Contributor

dsaxton commented Sep 20, 2020

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

pd.set_option("chained_assignment", "raise")

@samilAyoub
Copy link
Contributor Author

@dsaxton So we can modify the test to capture raising instead of warning when chained assignment is used.

@dsaxton
Copy link
Contributor

dsaxton commented Sep 20, 2020

@dsaxton So we can modify the test to capture raising instead of warning when chained assignment is used.

That seems reasonable

@samilAyoub samilAyoub requested a review from dsaxton September 21, 2020 10:18
Copy link
Contributor

@dsaxton dsaxton left a 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)

@dsaxton
Copy link
Contributor

dsaxton commented Sep 21, 2020

Also if you can now merge master that should fix the CI

Co-authored-by: Daniel Saxton <2658661+dsaxton@users.noreply.github.com>
@samilAyoub
Copy link
Contributor Author

@dsaxton did you mean merging master branch into this branch (add_test_subframe)?

@dsaxton
Copy link
Contributor

dsaxton commented Sep 21, 2020

@dsaxton did you mean merging master branch into this branch (add_test_subframe)?

Yes, actually it seems CI is fine so not really necessary

@samilAyoub
Copy link
Contributor Author

@dsaxton Thank you for your review !

tm.assert_frame_equal(df.iloc[0:5], df.loc[idx[0:5]])
tm.assert_frame_equal(df, df.loc[list(idx)])


Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure

Copy link
Contributor Author

@samilAyoub samilAyoub Sep 22, 2020

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.

@jreback jreback added this to the 1.2 milestone Sep 21, 2020
@jreback jreback added the Indexing Related to indexing on series/frames, not to indexes themselves label Sep 21, 2020
@jreback jreback merged commit d9722ef into pandas-dev:master Sep 22, 2020
@jreback
Copy link
Contributor

jreback commented Sep 22, 2020

thanks @samilAyoub

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Indexing Related to indexing on series/frames, not to indexes themselves Testing pandas testing functions or related to the test suite

5 participants