class StoreToH5(DataHandler): default_autotbl = None @only_root def __init__(self, destination=None): """ Store data to the specified .h5 destination. *destination* may be either a file name or an existing AutoTable object """ self.destination = destination if isinstance(destination, AutoTable): self.autotbl = destination elif isinstance(destination, str): self.autotbl = AutoTable(destination) elif destination is None: if StoreToH5.default_autotbl is None: self.autotbl = AutoTable() else: self.autotbl = StoreToH5.default_autotbl else: raise TypeError( "Expects an AutoTable instance or a string as argument") if StoreToH5.default_autotbl is None: StoreToH5.default_autotbl = self.autotbl def __repr__(self): if "destination" in self.__dict__: return "StoreToH5 into file %s" % self.destination else: return "Uninitialised hf5 logger" @only_root def append(self, tblname, value): self.autotbl.append(tblname, value) @only_root def extend(self, valdict): self.autotbl.extend(valdict) @only_root def close(self): self.autotbl.close()
class StoreToH5(DataHandler): default_autotbl = None def __init__(self, destination=None): """ Store data to the specified .h5 destination. *destination* may be either a file name or an existing AutoTable object """ self.destination = destination if comm.rank == 0: if isinstance(destination, AutoTable): self.autotbl = destination elif isinstance(destination, str): self.autotbl = AutoTable(destination) elif destination is None: if StoreToH5.default_autotbl is None: self.autotbl = AutoTable() else: self.autotbl = StoreToH5.default_autotbl else: raise TypeError( "Expects an AutoTable instance or a string as argument") if StoreToH5.default_autotbl is None: StoreToH5.default_autotbl = self.autotbl def __repr__(self): return "StoreToH5 into file %s" % self.destination def append(self, tblname, value): self.autotbl.append(tblname, value) def append_all(self, valdict): self.autotbl.append_all(valdict) def read(self, tblname, row): pass def close(self): #if comm.rank != 0: #return self.autotbl.close()
class StoreToH5(DataHandler): default_autotbl = None def __init__(self, destination=None): """ Store data to the specified .h5 destination. *destination* may be either a file name or an existing AutoTable object """ self.destination = destination if comm.rank == 0: if isinstance(destination, AutoTable): self.autotbl = destination elif isinstance(destination, str): self.autotbl = AutoTable(destination) elif destination is None: if StoreToH5.default_autotbl is None: self.autotbl = AutoTable() else: self.autotbl = StoreToH5.default_autotbl else: raise TypeError("Expects an AutoTable instance or a string as argument") if StoreToH5.default_autotbl is None: StoreToH5.default_autotbl = self.autotbl def __repr__(self): return "StoreToH5 into file %s" % self.destination def append(self, tblname, value): self.autotbl.append(tblname, value) def append_all(self, valdict): self.autotbl.append_all(valdict) def read(self, tblname, row): pass def close(self): #if comm.rank != 0: #return self.autotbl.close()
class StoreToH5(DataHandler): default_autotbl = None @only_root def __init__(self, destination=None): """ Store data to the specified .h5 destination. *destination* may be either a file name or an existing AutoTable object """ self.destination = destination if isinstance(destination, AutoTable): self.autotbl = destination elif isinstance(destination, str): self.autotbl = AutoTable(destination) elif destination is None: if StoreToH5.default_autotbl is None: self.autotbl = AutoTable() else: self.autotbl = StoreToH5.default_autotbl else: raise TypeError("Expects an AutoTable instance or a string as argument") if StoreToH5.default_autotbl is None: StoreToH5.default_autotbl = self.autotbl def __repr__(self): if "destination" in self.__dict__: return "StoreToH5 into file %s" % self.destination else: return "Uninitialised hf5 logger" @only_root def append(self, tblname, value): self.autotbl.append(tblname, value) @only_root def extend(self, valdict): self.autotbl.extend(valdict) @only_root def close(self): self.autotbl.close()
def hdf5write(path, name, variable): file_ = AutoTable(path) file_.append(name, variable) file_.close()