_database.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:ananke 作者: beiko-lab 项目源码 文件源码
def fill_array(self, target, value, chunk_size = 1000):
        """Fill the target HDF5 array with a single value. Useful for 
        initializing an array, since the rhdf5 package tends to segfault if you
        load an uninitialized data set.

        Parameters
        ----------
        target: str
            the location of the HDF5 array, e.g., "samples/time"
        value: any
            the value to fill the array with
        chunk_size: int
            the number of items to insert at a time. This only needs to be
            increased for very large data sets.
        """
        n = self.h5_table[target].shape[0]
        chunks = np.append(np.arange(0, n, chunk_size), n)
        for i in range(len(chunks)-1):
            self.h5_table[target][chunks[i]:chunks[i+1]] = (
                                            [value]*(chunks[i+1] - chunks[i]) )
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号