Source code for hetero.dynamics.base


import os
osjoin = os.path.join # an alias for convenience
import numpy as np
from hetero import utils


[docs] class Dynamic: """ Base class for for the `dynamic` object, that serves as containter for orchestrating the integration of the dynamical systems and storing them on the disk. Parameters ---------- sim_path : str Path of the simulation directory namespace : dict The dynaimc rule's argument (passed to the integrators) name : str Name of the specific dynamic rule ext : str The extension of the state file (pkl or npy) """ def __init__(self, sim_path, namespace, name, ext): self.sim_path = sim_path self.namespace = namespace self.name = name self.ext = ext
[docs] def prepare_nets(self): nets = utils.load_nets(self.sim_path) taus = utils.load_taus(self.sim_path) return nets, taus
[docs] def scan_for_undone(self, state_name): """Checks which networks are not yet integrated, and returns lists for the network ids and their corresponding time constants. These lists will be empty if all networks are integrated.""" # checking remaining nets net_ids, taus = self.prepare_nets() net_id_list = [] taus_list = [] for net_id, tau, in zip(net_ids, taus): savepath = osjoin(self.sim_path, net_id, f'{state_name}.{self.ext}') if os.path.exists(savepath): print(f'{net_id} exists - skipped. ') else: net_id_list.append(net_id) taus_list.append(tau) return net_id_list, taus_list