Module#
- class Module(name=None, label=None, **kwargs)[source]#
Bases:
Base
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”)
kwargs (dict) – passed to ss.Time() (e.g. start, stop, unit, dt)
Attributes
now
Shortcut to self.t.now()
Return a flat list of all states
Return a flat dictionary (objdict) of all states
ti
Get the current module timestep
timevec
Shortcut to self.t.timevec
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(force=False)[source]#
Initialize all time parameters by ensuring all parameters are initialized; part of init_post()
- match_time_inds(inds=None)[source]#
Find the nearest matching sim time indices for the current module
- 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