Skip to content
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

HDFStore.select_column error reporting #20705

Merged
merged 3 commits into from
Apr 16, 2018

Conversation

CianciuStyles
Copy link
Contributor

@gfyoung gfyoung added Error Reporting Incorrect or improved errors from pandas IO HDF5 read_hdf, HDFStore labels Apr 15, 2018
@@ -1094,7 +1093,8 @@ def get_storer(self, key):
""" return the storer object for a key, raise if not in the file """
group = self.get_node(key)
if group is None:
return None
raise KeyError('No object named %s in the file' % key)

Copy link
Member

Choose a reason for hiding this comment

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

Can we use the .format syntax here.

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, no problems.

# GH 17912
# HDFStore.select_column should raise a KeyError
# exception if the key is not a valid store
pytest.raises(KeyError, store.select_column, 'df', 'index')
Copy link
Member

Choose a reason for hiding this comment

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

Can we also check for the error message here?

@@ -887,7 +887,9 @@ def remove(self, key, where=None, start=None, stop=None):
where = _ensure_term(where, scope_level=1)
try:
s = self.get_storer(key)
except:
except KeyError as ke:
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this just be

except KeyError:
    raise

Maybe w/ a comment explaining what's going on. Or is that python 3 only?

Copy link
Member

Choose a reason for hiding this comment

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

@TomAugspurger : The syntax is supported in Python 2 and 3. This would be a good simplification.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've just checked the Python 2 docs, and it seems to be compatible with that version as well (https://docs.python.org/2.7/tutorial/errors.html). If you prefer this style, I'll change the code and add the comment.

Copy link
Member

Choose a reason for hiding this comment

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

This is pretty standard syntax IMO (we use in other places in other codebase), so I'm not sure how necessary commenting is. That being said, couldn't hurt, so let's just comment it :)

@pep8speaks
Copy link

pep8speaks commented Apr 15, 2018

Hello @CianciuStyles! Thanks for updating the PR.

Cheers ! There are no PEP8 issues in this Pull Request. 🍻

Comment last updated on April 15, 2018 at 21:00 Hours UTC

@codecov
Copy link

codecov bot commented Apr 15, 2018

Codecov Report

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

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #20705      +/-   ##
==========================================
- Coverage   91.84%   91.84%   -0.01%     
==========================================
  Files         153      153              
  Lines       49279    49279              
==========================================
- Hits        45259    45258       -1     
- Misses       4020     4021       +1
Flag Coverage Δ
#multiple 90.23% <75%> (ø) ⬆️
#single 41.9% <100%> (-0.01%) ⬇️
Impacted Files Coverage Δ
pandas/io/pytables.py 92.41% <100%> (-0.05%) ⬇️

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 d04b746...a9d4c6a. Read the comment docs.

@CianciuStyles
Copy link
Contributor Author

The latest push should address all the comments so far.

@jreback jreback changed the title Fix issue 17912 HDFStore.select_column error reporting Apr 16, 2018
@jreback jreback added this to the 0.23.0 milestone Apr 16, 2018
@jreback jreback merged commit 804101c into pandas-dev:master Apr 16, 2018
@jreback
Copy link
Contributor

jreback commented Apr 16, 2018

thanks @CianciuStyles nice patch!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Error Reporting Incorrect or improved errors from pandas IO HDF5 read_hdf, HDFStore
Projects
None yet
Development

Successfully merging this pull request may close these issues.

HDFStore.select_column
5 participants