-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
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
REF/TST: Add more pytest idiom to indexing/multiindex/test_getitem.py #24053
Conversation
Hello @simonjayhawkins! Thanks for updating the PR.
Comment last updated on December 10, 2018 at 16:06 Hours UTC |
result = s.xs('one', level='L2') | ||
expected = Series([1, 3], index=['a', 'b']) | ||
expected.index.set_names(['L1'], inplace=True) | ||
tm.assert_series_equal(result, expected) |
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 we break this massive test up into smaller ones?
tm.assert_series_equal(result, expected) | ||
|
||
|
||
def test_getitem_duplicates_multiindex(): |
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 try to parameteize this on the input frame / expected output.
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.
might make sense to split out the empty case to a new test
df['foo']['one'] = 2 | ||
return df | ||
|
||
pytest.raises(com.SettingWithCopyError, f) |
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.
Any error message worth checking?
Codecov Report
@@ Coverage Diff @@
## master #24053 +/- ##
=======================================
Coverage 42.45% 42.45%
=======================================
Files 161 161
Lines 51561 51561
=======================================
Hits 21888 21888
Misses 29673 29673
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #24053 +/- ##
=======================================
Coverage 92.21% 92.21%
=======================================
Files 162 162
Lines 51761 51761
=======================================
Hits 47731 47731
Misses 4030 4030
Continue to review full report at Codecov.
|
tm.assert_series_equal(result, expected) | ||
|
||
# xs | ||
result = s.xs(0, level=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.
@jreback should this be result = s.xs(0, level=1)
?
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 could then paramatrize..
@pytest.mark.parametrize('access_method', [lambda s, x: s[:, x],
lambda s, x: s.loc[:, x],
lambda s, x: s.xs(x, level=1)])
@pytest.mark.parametrize('level1_value, expected', [
(0, Series([1], index=[0])),
(1, Series([2, 3], index=[1, 2]))
])
def test_series_getitem_multiindex(access_method, level1_value, expected):
# GH 6018
# series regression getitem with a multi-index
s = Series([1, 2, 3])
s.index = MultiIndex.from_tuples([(0, 0), (1, 1), (2, 1)])
result = access_method(s, level1_value)
tm.assert_series_equal(result, expected)
or is this OTT.
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.
no, you certainly parameterize this
thanks @simonjayhawkins keep em coming! I don't mind bigger ones, main issue is there are some other parts moving so easiest to get them in in self-contained units. |
* upstream/master: pct change bug issue 21200 (pandas-dev#21235) DOC: Fix summaries not ending with a period (pandas-dev#24190) DOC: Add back currentmodule to api.rst (pandas-dev#24232) DOC: Fixed implicit imports for whatsnew (v >= version 20.0) (pandas-dev#24199) remove enum import for PY2 compat, xref pandas-dev#22802 (pandas-dev#24170) CI: Simplify Azure Pipelines configuration files (pandas-dev#23111) REF/TST: Add more pytest idiom to indexing/multiindex/test_getitem.py (pandas-dev#24053)
xref #24040
for this pass:
the Test classes have been removed.
catch_warnings
used for the.ix
deprecation replaced with@pytest.mark.filterwarnings("ignore:\\n.ix:DeprecationWarning")
at test level.cc @jreback @gfyoung