refactored flows
@@ -95,10 +95,7 @@ class People(cvb.BasePeople):
self._lock = strict # If strict is true, stop further keys from being set (does not affect attributes)
# Store flows to be computed during simulation
- self.flows = {key:0 for key in cvd.new_result_flows}
- self.flows_strain = {}
- for key in cvd.new_result_flows_by_strain:
- self.flows_strain[key] = np.full(self.total_strains, 0, dtype=cvd.default_float)
+ self.init_flows()
# Although we have called init(), we still need to call initialize()
self.initialized = False
@@ -119,6 +116,15 @@ class People(cvb.BasePeople):
return
+ def init_flows(self):
+ ''' Initialize flows to be zero '''
+ self.flows = {key:0 for key in cvd.new_result_flows}
+ self.flows_strain = {}
+ for key in cvd.new_result_flows_by_strain:
+ self.flows_strain[key] = np.zeros(self.total_strains, dtype=cvd.default_float)
+ return
+
+
def initialize(self):
''' Perform initializations '''
self.set_prognoses()
@@ -169,10 +175,7 @@ class People(cvb.BasePeople):
self.is_exp = self.true('exposed') # For storing the interim values since used in every subsequent calculation
# Perform updates
- self.flows = {key:0 for key in cvd.new_result_flows}
- self.flows_strain = {}
- for key in cvd.new_result_flows_by_strain:
- self.flows_strain[key] = np.full(self.pars['total_strains'], 0, dtype=cvd.default_float)
+ self.init_flows()
self.flows['new_infectious'] += self.check_infectious() # For people who are exposed and not infectious, check if they begin being infectious
self.flows['new_symptomatic'] += self.check_symptomatic()
self.flows['new_severe'] += self.check_severe()
