Skip to content

Commit a5912b3

Browse files
authored
Change usages of datetime.date to tlo.Date in lifestyle module (#944)
1 parent 0462fbe commit a5912b3

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/tlo/methods/enhanced_lifestyle.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
22
Lifestyle module
33
Documentation: 04 - Methods Repository/Method_Lifestyle.xlsx
44
"""
5-
import datetime
65
from pathlib import Path
76

87
import numpy as np
98
import pandas as pd
109

11-
from tlo import DateOffset, Module, Parameter, Property, Types, logging
10+
from tlo import Date, DateOffset, Module, Parameter, Property, Types, logging
1211
from tlo.events import PopulationScopeEventMixin, RegularEvent
1312
from tlo.util import get_person_id_to_inherit_from
1413

@@ -344,9 +343,9 @@ def read_parameters(self, data_folder):
344343

345344
self.load_parameters_from_dataframe(dfd)
346345
# Manually set dates for campaign starts for now todo - fix this
347-
p['start_date_campaign_exercise_increase'] = datetime.date(2010, 7, 1)
348-
p['start_date_campaign_quit_smoking'] = datetime.date(2010, 7, 1)
349-
p['start_date_campaign_alcohol_reduction'] = datetime.date(2010, 7, 1)
346+
p['start_date_campaign_exercise_increase'] = Date(2010, 7, 1)
347+
p['start_date_campaign_quit_smoking'] = Date(2010, 7, 1)
348+
p['start_date_campaign_alcohol_reduction'] = Date(2010, 7, 1)
350349

351350
def initialise_population(self, population):
352351
"""Set our property values for the initial population.
@@ -1286,7 +1285,7 @@ def apply(self, population):
12861285
newly_not_high_salt_idx = high_salt_idx[random_draw < eff_rate_not_high_salt]
12871286
df.loc[newly_not_high_salt_idx, 'li_high_salt'] = False
12881287

1289-
all_idx_campaign_salt_reduction = df.index[df.is_alive & (self.sim.date == datetime.date(2010, 7, 1))]
1288+
all_idx_campaign_salt_reduction = df.index[df.is_alive & (self.sim.date == Date(2010, 7, 1))]
12901289
df.loc[all_idx_campaign_salt_reduction, 'li_exposed_to_campaign_salt_reduction'] = True
12911290

12921291
# -------------------- HIGH SUGAR ----------------------------------------------------------
@@ -1307,7 +1306,7 @@ def apply(self, population):
13071306
newly_not_high_sugar_idx = high_sugar_idx[random_draw < eff_rate_not_high_sugar]
13081307
df.loc[newly_not_high_sugar_idx, 'li_high_sugar'] = False
13091308

1310-
all_idx_campaign_sugar_reduction = df.index[df.is_alive & (self.sim.date == datetime.date(2010, 7, 1))]
1309+
all_idx_campaign_sugar_reduction = df.index[df.is_alive & (self.sim.date == Date(2010, 7, 1))]
13111310
df.loc[all_idx_campaign_sugar_reduction, 'li_exposed_to_campaign_sugar_reduction'] = True
13121311

13131312
# -------------------- BMI ----------------------------------------------------------
@@ -1348,7 +1347,7 @@ def apply(self, population):
13481347
newly_decrease_bmi_cat_idx = bmi_cat_3_to_5_idx[random_draw < eff_rate_lower_bmi]
13491348
df.loc[newly_decrease_bmi_cat_idx, 'li_bmi'] = df['li_bmi'] - 1
13501349

1351-
all_idx_campaign_weight_reduction = df.index[df.is_alive & (self.sim.date == datetime.date(2010, 7, 1))]
1350+
all_idx_campaign_weight_reduction = df.index[df.is_alive & (self.sim.date == Date(2010, 7, 1))]
13521351
df.loc[all_idx_campaign_weight_reduction, 'li_exposed_to_campaign_weight_reduction'] = True
13531352

13541353
# --- FSW ---

0 commit comments

Comments
 (0)