-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Fixturize tests/frame/test_indexing.py #25633
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
Fixturize tests/frame/test_indexing.py #25633
Conversation
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.
see comments. I don't really like to have multiple fixtures injected that are used in parts of tests. its just plain confusing (I know we let some thru before, but let's not do that anymore)
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.
Reflecting the points happening across several of these PRs, I'll:
- keep the
TestData
"fixtures" intests.frame.conftest
- any new fixtures will stay in their respective modules
- the effort for TST/CLN: remove TestData from frame-tests; replace with fixtures #22471 is strictly translation, no breakup of tests
Codecov Report
@@ Coverage Diff @@
## master #25633 +/- ##
=======================================
Coverage 91.26% 91.26%
=======================================
Files 173 173
Lines 52968 52968
=======================================
Hits 48339 48339
Misses 4629 4629
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #25633 +/- ##
==========================================
+ Coverage 91.84% 91.85% +<.01%
==========================================
Files 180 174 -6
Lines 50734 50722 -12
==========================================
- Hits 46599 46589 -10
+ Misses 4135 4133 -2
Continue to review full report at Codecov.
|
@jreback |
@@ -127,6 +127,17 @@ def timezone_frame(): | |||
return df | |||
|
|||
|
|||
@pytest.fixture | |||
def uint64_frame(): | |||
""" |
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.
instead of this can you just use the mixed_int_frame (maybe even add a column to it if needed)
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.
Nope, not changing the semantics of tests here. Just translating.
pandas/tests/frame/test_indexing.py
Outdated
piece = self.frame.loc[self.frame.index[:2], ['A', 'B']] | ||
self.frame.loc[self.frame.index[-2]:, ['A', 'B']] = piece.values | ||
result = self.frame.loc[self.frame.index[-2:], ['A', 'B']].values | ||
def test_setitem_frame(self, float_frame, float_string_frame): |
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.
parametrize or split test
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.
ok with splitting this test
pandas/tests/frame/test_indexing.py
Outdated
assert result == expected | ||
|
||
def test_lookup(self): | ||
def test_lookup(self, float_frame, float_string_frame): |
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
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, see if you can split the test
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.
@jreback
You always insist on keeping PRs focused on one thing. Please don't try to force changing tests in a PR that is strictly for translation.
If you want to split tests, I'll do it as simply as possible (barring someone showing me some fixture magic that I'm not aware of).
@@ -127,6 +127,17 @@ def timezone_frame(): | |||
return df | |||
|
|||
|
|||
@pytest.fixture | |||
def uint64_frame(): | |||
""" |
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.
Nope, not changing the semantics of tests here. Just translating.
@jreback |
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.
frame/test_indexing.py is actually pretty huge. so pls change according to my comments, and open an issue to split this to separate smaller files (after)
pandas/tests/frame/test_indexing.py
Outdated
piece = self.frame.loc[self.frame.index[:2], ['A', 'B']] | ||
self.frame.loc[self.frame.index[-2]:, ['A', 'B']] = piece.values | ||
result = self.frame.loc[self.frame.index[-2:], ['A', 'B']].values | ||
def test_setitem_frame(self, float_frame, float_string_frame): |
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.
ok with splitting this test
pandas/tests/frame/test_indexing.py
Outdated
assert result == expected | ||
|
||
def test_lookup(self): | ||
def test_lookup(self, float_frame, float_string_frame): |
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, see if you can split the test
This reverts commit d539d97.
this one might be ok, merge master and ping on green. |
closing as stale |
Sorry, I overlooked the request to merge master (busy times last month). Please reopen and I'll happily update. |
@h-vetinari can you merge master Conflicting files |
@simonjayhawkins Thanks for reopening; merged master. |
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.
anyplace you are adding multiple fixtures should have the tests splits; there are only a couple and shouldn't be a big deal to do
@@ -1329,15 +1331,15 @@ def test_getitem_fancy_1d(self): | |||
# slice of mixed-frame |
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 split this test
def test_xs(self): | ||
idx = self.frame.index[5] | ||
xs = self.frame.xs(idx) | ||
def test_xs(self, float_frame, datetime_frame): |
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 split
@@ -2582,7 +2593,8 @@ def test_boolean_indexing_mixed(self): | |||
with pytest.raises(TypeError, match=msg): | |||
df[df > 0.3] = 1 | |||
|
|||
def test_where(self): | |||
def test_where(self, float_string_frame, mixed_float_frame, |
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 split
pls merge master and will look again |
Thanks for taking care of this! |
thanks @h-vetinari |
One more step towards #22471. Happy to move the fixture to the
test_indexing
module if that's now the preferred form.