diff options
author | Étienne Simon <esimon@esimon.eu> | 2015-05-11 21:20:11 +0000 |
---|---|---|
committer | Étienne Simon <esimon@esimon.eu> | 2015-05-11 21:20:11 +0000 |
commit | bfda3532ea58a48533ceaa417b1bd5c3f5137be3 (patch) | |
tree | b52802e8b56cbf0c9931918b4cabb784b22e2631 /data/hdf5.py | |
parent | aa605460eb5891b64b4e795cbeff9cab474dee0d (diff) | |
download | taxi-bfda3532ea58a48533ceaa417b1bd5c3f5137be3.tar.gz taxi-bfda3532ea58a48533ceaa417b1bd5c3f5137be3.zip |
Add method to TaxiDataset to easily extract a dictionary
Diffstat (limited to 'data/hdf5.py')
-rw-r--r-- | data/hdf5.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/data/hdf5.py b/data/hdf5.py index d848023..6e2f9a4 100644 --- a/data/hdf5.py +++ b/data/hdf5.py @@ -19,6 +19,11 @@ class TaxiDataset(H5PYDataset): def data_path(self): return os.path.join(data.path, self.filename) + def extract(self, request): + if not self.load_in_memory: + raise ValueError('extract called on a dataset not loaded in memory') + return dict(zip(self.sources, self.get_data(None, request))) + class TaxiStream(DataStream): def __init__(self, which_set, filename='data.hdf5', iteration_scheme=None, **kwargs): dataset = TaxiDataset(which_set, filename, **kwargs) |