Skip to content

ENH: add contextmanager to HDFStore (#8791) #8958

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 1 commit into from
Dec 4, 2014
Merged

Conversation

vikram
Copy link

@vikram vikram commented Dec 2, 2014

Added a context manager to HDFStore

closes #8791

@jreback
Copy link
Contributor

jreback commented Dec 2, 2014

this is fine

pls add a release note in the enhancements section
pls review the docs in io.rst to see if anything needs to be changed

@jreback jreback added Enhancement IO HDF5 read_hdf, HDFStore labels Dec 2, 2014
@jreback jreback modified the milestones: 0.16.0, 0.15.2 Dec 2, 2014
@vikram
Copy link
Author

vikram commented Dec 2, 2014

@jreback I've updated the docs. Not sure if I've got it right.

@jreback
Copy link
Contributor

jreback commented Dec 2, 2014

pls squash, otherwise looks ok.

get_store now looks superfluous. Maybe we should deprecate in future versions?

@jorisvandenbossche

@jorisvandenbossche jorisvandenbossche changed the title Fixed #8791 add contextmanager ENH: add contextmanager to HDFStore (#8791) Dec 2, 2014
@vikram
Copy link
Author

vikram commented Dec 2, 2014

@jreback I've added warning that get_store is deprecated

@@ -72,6 +72,7 @@ Enhancements
- ``Timedelta`` arithmetic returns ``NotImplemented`` in unknown cases, allowing extensions by custom classes (:issue:`8813`).
- ``Timedelta`` now supports arithemtic with ``numpy.ndarray`` objects of the appropriate dtype (numpy 1.8 or newer only) (:issue:`8884`).
- Added ``Timedelta.to_timedelta64`` method to the public API (:issue:`8884`).
- Added context manager to ``HDFStore`` (:issue:`8791`). get_store still works. Now with HDFStore('path') as store: should also close to store. get_store will be deprecated, warning added.
Copy link
Contributor

Choose a reason for hiding this comment

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

take out the get_store still works..

@jorisvandenbossche
Copy link
Member

On the deprecation, I don't know if it is needed to really deprecate it, maybe we could only do "deprecation by documentation" (-> keeping it as an alias (and indicate this in the docstring of get_store) but use HDFStore everywhere in the documentation)

@vikram
Copy link
Author

vikram commented Dec 3, 2014

@jorisvandenbossche @jreback so I've made those changes. Sorry misunderstood that you guys wanted it deprecated.

@jreback
Copy link
Contributor

jreback commented Dec 3, 2014

ok, pls add a release note (put in enhancements section)

@@ -1288,6 +1267,9 @@ def _read_group(self, group, **kwargs):
return s.read(**kwargs)


get_store = HDFStore
Copy link
Member

Choose a reason for hiding this comment

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

I think we should add here something to the docstring of get_store that is is an alias of HDFStore -> better to use that.
You can use pd.util.decorators.Appender for that. Something like:

get_store = Appender("Backwards compatible alias for ``HDFStore``", join='\n')(HDFStore)

Copy link
Author

Choose a reason for hiding this comment

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

I've added that now.

instead of having to use

with get_store('file.h5') as store:
    store.keys()

now we can do

with HDFStore('file.h5') as store:
    store.keys()
@jreback
Copy link
Contributor

jreback commented Dec 4, 2014

looks ok to me. ping on green.

@vikram
Copy link
Author

vikram commented Dec 4, 2014

@jreback it's green

@jreback jreback merged commit 924c62e into pandas-dev:master Dec 4, 2014
@jreback
Copy link
Contributor

jreback commented Dec 4, 2014

@vikram thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement IO HDF5 read_hdf, HDFStore
Projects
None yet
Development

Successfully merging this pull request may close these issues.

HDFStore to work with 'with' statements
3 participants