2
2
Lifestyle module
3
3
Documentation: 04 - Methods Repository/Method_Lifestyle.xlsx
4
4
"""
5
- import datetime
6
5
from pathlib import Path
7
6
8
7
import numpy as np
9
8
import pandas as pd
10
9
11
- from tlo import DateOffset , Module , Parameter , Property , Types , logging
10
+ from tlo import Date , DateOffset , Module , Parameter , Property , Types , logging
12
11
from tlo .events import PopulationScopeEventMixin , RegularEvent
13
12
from tlo .util import get_person_id_to_inherit_from
14
13
@@ -344,9 +343,9 @@ def read_parameters(self, data_folder):
344
343
345
344
self .load_parameters_from_dataframe (dfd )
346
345
# 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 )
350
349
351
350
def initialise_population (self , population ):
352
351
"""Set our property values for the initial population.
@@ -1286,7 +1285,7 @@ def apply(self, population):
1286
1285
newly_not_high_salt_idx = high_salt_idx [random_draw < eff_rate_not_high_salt ]
1287
1286
df .loc [newly_not_high_salt_idx , 'li_high_salt' ] = False
1288
1287
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 ))]
1290
1289
df .loc [all_idx_campaign_salt_reduction , 'li_exposed_to_campaign_salt_reduction' ] = True
1291
1290
1292
1291
# -------------------- HIGH SUGAR ----------------------------------------------------------
@@ -1307,7 +1306,7 @@ def apply(self, population):
1307
1306
newly_not_high_sugar_idx = high_sugar_idx [random_draw < eff_rate_not_high_sugar ]
1308
1307
df .loc [newly_not_high_sugar_idx , 'li_high_sugar' ] = False
1309
1308
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 ))]
1311
1310
df .loc [all_idx_campaign_sugar_reduction , 'li_exposed_to_campaign_sugar_reduction' ] = True
1312
1311
1313
1312
# -------------------- BMI ----------------------------------------------------------
@@ -1348,7 +1347,7 @@ def apply(self, population):
1348
1347
newly_decrease_bmi_cat_idx = bmi_cat_3_to_5_idx [random_draw < eff_rate_lower_bmi ]
1349
1348
df .loc [newly_decrease_bmi_cat_idx , 'li_bmi' ] = df ['li_bmi' ] - 1
1350
1349
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 ))]
1352
1351
df .loc [all_idx_campaign_weight_reduction , 'li_exposed_to_campaign_weight_reduction' ] = True
1353
1352
1354
1353
# --- FSW ---
0 commit comments