Skip to content

Commit 1ad0530

Browse files
committed
Move new method below constructor
1 parent 4fe0920 commit 1ad0530

File tree

1 file changed

+19
-20
lines changed

1 file changed

+19
-20
lines changed

src/penn_chime/models.py

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -27,26 +27,6 @@
2727

2828

2929
class SimSirModel:
30-
31-
def gen_policy(self, p: Parameters) -> List[Tuple[float, int]]:
32-
if p.mitigation_date is not None:
33-
mitigation_day = -(p.current_date - p.mitigation_date).days
34-
else:
35-
mitigation_day = 0
36-
37-
total_days = self.i_day + p.n_days
38-
39-
if mitigation_day < -self.i_day:
40-
mitigation_day = -self.i_day
41-
42-
pre_mitigation_days = self.i_day + mitigation_day
43-
post_mitigation_days = total_days - pre_mitigation_days
44-
45-
return [
46-
(self.beta, pre_mitigation_days),
47-
(self.beta_t, post_mitigation_days),
48-
]
49-
5030
def __init__(self, p: Parameters):
5131

5232
self.rates = {
@@ -164,6 +144,25 @@ def __init__(self, p: Parameters):
164144
self.daily_growth_rate = get_growth_rate(p.doubling_time)
165145
self.daily_growth_rate_t = get_growth_rate(self.doubling_time_t)
166146

147+
def gen_policy(self, p: Parameters) -> List[Tuple[float, int]]:
148+
if p.mitigation_date is not None:
149+
mitigation_day = -(p.current_date - p.mitigation_date).days
150+
else:
151+
mitigation_day = 0
152+
153+
total_days = self.i_day + p.n_days
154+
155+
if mitigation_day < -self.i_day:
156+
mitigation_day = -self.i_day
157+
158+
pre_mitigation_days = self.i_day + mitigation_day
159+
post_mitigation_days = total_days - pre_mitigation_days
160+
161+
return [
162+
(self.beta, pre_mitigation_days),
163+
(self.beta_t, post_mitigation_days),
164+
]
165+
167166
def run_projection(self, p: Parameters, policy: List[Tuple[float, int]]):
168167
self.raw_df = sim_sir_df(
169168
self.susceptible,

0 commit comments

Comments
 (0)