def activate(layer, silent=False): """ Activates one or several layers. :param layer: String with layer name to activate (alternatively: list of layer names) """ from pyrat import data data.activateLayer(layer, silent=silent)
def activate(*args, silent=False, **kwargs): """ Activates one or several layers. :param layer: String with layer name to activate (alternatively: list of layer names) :param silent: stay silent, do not print output """ from pyrat import data if 'layer' in kwargs: layer = kwargs['layer'] elif len(args) > 0: layer = args[0] if len(layer) > 0: data.activateLayer(layer, silent=silent)
def defreeze(filename, *args, **kwargs): """ Restores are previously session saved with 'freeze' Example: var1, var2, var3 = defreeze("session.hd5") :param filename: Session file saved with 'freeze' :return: Additional variables stored during the freeze process. """ from pyrat import data file = h5py.File(filename, 'r') data.layers = {} local_var = () for layer in file: if layer != 'locals': fn = tempfile.mktemp(suffix='.hd5', prefix='pyrat_', dir=data.tmpdir) print("Reading layer", layer, fn) out = h5py.File(fn, 'w') h5py.h5o.copy(file.id, str.encode(layer + '/D'), out.id, str.encode("D")) obj = pickle.loads((bytes(file[layer]['pickle'][...]))) data.layers['/' + layer] = obj data.layers['/' + layer].fn = fn data.layers['/' + layer].file = h5py.File(fn, 'a') data.layers['/' + layer].group = data.layers['/' + layer].file['/D'] else: local_var = pickle.loads((bytes(file['locals'][...]))) data.laynam = file.attrs["laynam"] active = file.attrs["active"] if isinstance(active, str): data.active = active else: data.active = list(active.astype("U")) file.close() data.activateLayer(data.active, silent=True) if len(local_var) > 0: return local_var
def activate(layer, silent=False): from pyrat import data data.activateLayer(layer, silent=silent)