def read_h5(tasks, name: str, file_name: str, dataset_path: str, offset: tuple, output_chunk_name: str): """Read HDF5 files.""" for task in tasks: start = time() assert output_chunk_name not in task task[output_chunk_name] = Chunk.from_h5(file_name, dataset_path=dataset_path, global_offset=offset) task['log']['timer'][name] = time() - start yield task
def read_write_h5(chunk): assert isinstance(chunk, Chunk) file_name = 'test.h5' if os.path.exists(file_name): os.remove(file_name) chunk.to_h5(file_name, chunk_size=None) chunk2 = Chunk.from_h5(file_name) assert chunk == chunk2 assert chunk.voxel_offset == chunk2.voxel_offset os.remove(file_name)
def read_write_h5(chunk): assert isinstance(chunk, np.ndarray) file_name = 'test.h5' if os.path.exists(file_name): os.remove(file_name) chunk.to_h5(file_name) chunk2 = Chunk.from_h5(file_name) assert np.alltrue(chunk == chunk2) assert chunk.global_offset == chunk2.global_offset os.remove(file_name)