Module#
- class Module(name=None, label=None, unit=None, dt=None)[source]#
Bases:
quickobj
The main base class for all Starsim modules: diseases, networks, interventions, etc.
- Parameters:
name (str) – a short, key-like name for the module (e.g. “randomnet”)
label (str) – the full, human-readable name for the module (e.g. “Random network”)
unit (str) – the time unit (e.g. ‘day’, ‘year’); inherits from sim if not supplied
dt (float) – the timestep (e.g. 1.0, 0.1); inherits from sim if not supplied
Attributes
Return the current time, i.e. the time vector at the current timestep.
Return a flat list of all states
Return a flat dictionary (objdict) of all states
Methods
- init_pre(sim, force=False)[source]#
Perform initialization steps
This method is called once, as part of initializing a Sim. Note: after initialization, initialized=False until init_vals() is called (which is after distributions are initialized).
- init_time_pars(force=False)[source]#
Initialize all time parameters by ensuring all parameters are initialized; part of init_post()
- property now#
Return the current time, i.e. the time vector at the current timestep
- define_states(*args, check=True)[source]#
Define states of the module with the same attribute name as the state
- Parameters:
args (states) – list of states to add
check (bool) – whether to check that the object being added is a state
- property states#
Return a flat list of all states
The base class returns all states that are contained in top-level attributes of the Module. If a Module stores states in a non-standard location (e.g., within a list of states, or otherwise in some other nested structure - perhaps due to supporting features like multiple genotypes) then the Module should overload this attribute to ensure that all states appear in here.
- property statesdict#
Return a flat dictionary (objdict) of all states
Note that name collisions may affect the output of this function