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

allow passing pytables options on load #40

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions deepdish/io/hdf5io.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from deepdish import conf
try:
import pandas as pd
pd.io.pytables._tables()
_pandas = True
except ImportError:
_pandas = False
Expand Down Expand Up @@ -248,7 +249,7 @@ def _save_level(handler, group, level, name=None, filters=None, idtable=None):
elif isinstance(level, np.ndarray):
_save_ndarray(handler, group, name, level, filters=filters)

elif _pandas and isinstance(level, (pd.DataFrame, pd.Series, pd.Panel)):
elif _pandas and isinstance(level, (pd.DataFrame, pd.Series)):
store = _HDFStoreWithHandle(handler)
store.put(group._v_pathname + '/' + name, level)

Expand Down Expand Up @@ -598,7 +599,7 @@ def save(path, data, compression='default'):
group._v_attrs[DEEPDISH_IO_UNPACK] = True


def load(path, group=None, sel=None, unpack=False):
def load(path, group=None, sel=None, unpack=False, pytables_kwargs={}):
"""
Loads an HDF5 saved with `save`.

Expand All @@ -621,6 +622,8 @@ def load(path, group=None, sel=None, unpack=False):
If True, a single-entry dictionaries will be unpacked and the value
will be returned directly. That is, if you save ``dict(a=100)``, only
``100`` will be loaded.
pytables_kwargs : dict
Keyword arguments to pass to pytables when opening a file.

Returns
-------
Expand All @@ -632,7 +635,7 @@ def load(path, group=None, sel=None, unpack=False):
save

"""
with tables.open_file(path, mode='r') as h5file:
with tables.open_file(path, mode='r', **pytables_kwargs) as h5file:
pathtable = {} # dict to keep track of objects already loaded
if group is not None:
if isinstance(group, str):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

args = dict(
name='deepdish',
version='0.3.4',
version='0.3.4.1',
url="https://github.com/uchicago-cs/deepdish",
description="Deep Learning experiments from University of Chicago.",
maintainer='Gustav Larsson',
Expand Down