def append(self, array):
"""Append data from `array` to self."""
if self.closed:
raise ValueError('Array is not opened.')
if not self.initialized:
self.init_from_array(array)
if array.shape[1:] != self.shape[1:]:
raise ValueError("Appended array is of different shape.")
elif array.dtype != self.dtype:
raise ValueError("Appended array is of different dtype.")
# Append new data
pos = self.header_length + self.size * self.itemsize
self.fs.seek(pos)
self.fs.write(array.tobytes('C'))
self.shape = (self.shape[0] + len(array), ) + self.shape[1:]
# Only prepare the header bytes, need to be flushed to take effect
self._prepare_header_data()
# Invalidate the memmap
self._memmap = None
评论列表
文章目录