From b10a475433591edd639e906182a7f195d089a10f Mon Sep 17 00:00:00 2001 From: Thomas Fillon Date: Mon, 20 Oct 2014 16:50:10 +0200 Subject: [PATCH] fix(tools.buffering): allow proper array concatenation in BufferTable --- timeside/tools/buffering.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/timeside/tools/buffering.py b/timeside/tools/buffering.py index e49bb28..bcc4e0e 100644 --- a/timeside/tools/buffering.py +++ b/timeside/tools/buffering.py @@ -22,7 +22,7 @@ import tables from tempfile import NamedTemporaryFile - +import numpy as np class BufferTable(object): def __init__(self, array_names=None): @@ -49,7 +49,11 @@ class BufferTable(object): def append(self, name, new_array): try: - self.fileh.root.__getattr__(name).append([new_array]) + if new_array.shape: + self.fileh.root.__getattr__(name).append(new_array[np.newaxis, + :]) + else: + self.fileh.root.__getattr__(name).append([new_array]) except tables.exceptions.NoSuchNodeError: if name not in self.array_names: self.array_names.append(name) @@ -58,10 +62,10 @@ class BufferTable(object): # name=name, # obj=[new_array]) atom = tables.Atom.from_dtype(new_array.dtype) - if len(new_array.shape) > 1: - shape = (0, new_array.shape[1]) - else: - shape = (0,) + dim_list = [0] + dim_list.extend([dim for dim in new_array.shape]) + shape = tuple(dim_list) + self.fileh.createEArray(where=self.fileh.root, name=name, atom=atom, -- 2.39.5