commit bfda3532ea58a48533ceaa417b1bd5c3f5137be3
parent aa605460eb5891b64b4e795cbeff9cab474dee0d
Author: Étienne Simon <esimon@esimon.eu>
Date: Mon, 11 May 2015 21:20:11 +0000
Add method to TaxiDataset to easily extract a dictionary
Diffstat:
1 file changed, 5 insertions(+), 0 deletions(-)
diff --git 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)