]> git.parisson.com Git - timeside.git/commitdiff
fix(tools.buffering): allow proper array concatenation in BufferTable
authorThomas Fillon <thomas@parisson.com>
Mon, 20 Oct 2014 14:50:10 +0000 (16:50 +0200)
committerThomas Fillon <thomas@parisson.com>
Mon, 20 Oct 2014 14:50:10 +0000 (16:50 +0200)
timeside/tools/buffering.py

index e49bb28723397941fc55f136943134e8d0c40df2..bcc4e0e4b40af619e149557c40fb3672afa252d5 100644 (file)
@@ -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,