Skip to content

STY: use pytest.raises context syntax (groupby) #24828

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

Merged
merged 4 commits into from
Jan 20, 2019

Conversation

simonjayhawkins
Copy link
Member

xref #24332

s.groupby(level=[0, 0])
with pytest.raises(ValueError, match=msg):
s.groupby(level=[0, 1])
msg = "level > 0 or level < -1 only valid with MultiIndex"
Copy link
Member Author

Choose a reason for hiding this comment

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

i should probably remove the double space as well?

Copy link
Member

Choose a reason for hiding this comment

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

Good catch and yes that would be good

Copy link
Member

@WillAyd WillAyd left a comment

Choose a reason for hiding this comment

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

Minor stylistic nits but generally looks good

@@ -26,9 +26,9 @@ class TestSelection(object):
def test_select_bad_cols(self):
df = DataFrame([[1, 2]], columns=['A', 'B'])
g = df.groupby('A')
pytest.raises(KeyError, g.__getitem__, ['C']) # g[['C']]
with pytest.raises(KeyError, match='"Columns not found: '"'C'"'"'):
Copy link
Member

Choose a reason for hiding this comment

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

Also tough to read with quoting - can you not just escape what you need to?

@WillAyd WillAyd added Testing pandas testing functions or related to the test suite Clean labels Jan 18, 2019
@codecov
Copy link

codecov bot commented Jan 18, 2019

Codecov Report

Merging #24828 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master   #24828   +/-   ##
=======================================
  Coverage   92.38%   92.38%           
=======================================
  Files         166      166           
  Lines       52383    52383           
=======================================
  Hits        48396    48396           
  Misses       3987     3987
Flag Coverage Δ
#multiple 90.81% <100%> (ø) ⬆️
#single 42.91% <0%> (ø) ⬆️
Impacted Files Coverage Δ
pandas/core/groupby/groupby.py 96.8% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 08f92c4...f2fab1d. Read the comment docs.

@codecov
Copy link

codecov bot commented Jan 18, 2019

Codecov Report

Merging #24828 into master will decrease coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #24828      +/-   ##
==========================================
- Coverage   92.38%   92.38%   -0.01%     
==========================================
  Files         166      166              
  Lines       52383    52383              
==========================================
- Hits        48396    48395       -1     
- Misses       3987     3988       +1
Flag Coverage Δ
#multiple 90.81% <100%> (ø) ⬆️
#single 42.91% <0%> (ø) ⬆️
Impacted Files Coverage Δ
pandas/core/groupby/groupby.py 96.8% <100%> (ø) ⬆️
pandas/core/groupby/grouper.py 98.16% <100%> (ø) ⬆️
pandas/util/testing.py 88.04% <0%> (-0.1%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 08f92c4...f2fab1d. Read the comment docs.

@simonjayhawkins
Copy link
Member Author

thanks for the review @WillAyd. have made changes as requested.

@jreback jreback added this to the 0.24.0 milestone Jan 19, 2019
@jreback jreback added the Code Style Code style, linting, code_checks label Jan 19, 2019
@jreback
Copy link
Contributor

jreback commented Jan 19, 2019

lgtm. @WillAyd merge when ok.

@WillAyd WillAyd merged commit 518b237 into pandas-dev:master Jan 20, 2019
@WillAyd
Copy link
Member

WillAyd commented Jan 20, 2019

Thanks @simonjayhawkins

@gfyoung gfyoung added the Error Reporting Incorrect or improved errors from pandas label Jan 20, 2019
@simonjayhawkins simonjayhawkins deleted the cm-groupby branch January 20, 2019 22:33
Pingviinituutti pushed a commit to Pingviinituutti/pandas that referenced this pull request Feb 28, 2019
Pingviinituutti pushed a commit to Pingviinituutti/pandas that referenced this pull request Feb 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Clean Code Style Code style, linting, code_checks Error Reporting Incorrect or improved errors from pandas Testing pandas testing functions or related to the test suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants