Skip to content

Commit da83f0d

Browse files
authored
Update RTI to work on latest version of Numpy+Pandas (#1827)
* Cast category to str values to applymap works properly in v2.3.3 of Pandas * Get single sample, not array of size 1, so cast to int works in latest Numpy
1 parent 96e6644 commit da83f0d

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/tlo/methods/rti.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2133,7 +2133,7 @@ def rti_assign_daly_weights(self, injured_index):
21332133
(sum(df.loc[injured_index, 'rt_imm_death']) == 0)
21342134
selected_for_rti_inj = df.loc[injured_index, RTI.INJURY_COLUMNS]
21352135

2136-
daly_change = selected_for_rti_inj.applymap(
2136+
daly_change = selected_for_rti_inj.astype('str').applymap(
21372137
lambda code: self.ASSIGN_INJURIES_AND_DALY_CHANGES[code][1]
21382138
).sum(axis=1, numeric_only=True)
21392139
df.loc[injured_index, 'rt_disability'] += daly_change
@@ -2287,7 +2287,7 @@ def rti_determine_LOS(self, person_id):
22872287
df = self.sim.population.props
22882288

22892289
def draw_days(_mean, _sd):
2290-
return int(self.rng.normal(_mean, _sd, 1))
2290+
return int(self.rng.normal(_mean, _sd))
22912291

22922292
# Create the length of stays required for each ISS score boundaries and check that they are >=0
22932293
rt_iss_score = df.at[person_id, 'rt_ISS_score']
@@ -3804,9 +3804,9 @@ def apply(self, person_id, squeeze_factor):
38043804
codes = ['133', '133a', '133b', '133c', '133d' '134', '134a', '134b', '135']
38053805
_, counts = road_traffic_injuries.rti_find_and_count_injuries(person_injuries, codes)
38063806
if counts > 0:
3807-
self.icu_days = int(self.module.rng.normal(mean_tbi_icu_days, sd_tbi_icu_days, 1))
3807+
self.icu_days = int(self.module.rng.normal(mean_tbi_icu_days, sd_tbi_icu_days))
38083808
else:
3809-
self.icu_days = int(self.module.rng.normal(mean_icu_days, sd_icu_days, 1))
3809+
self.icu_days = int(self.module.rng.normal(mean_icu_days, sd_icu_days))
38103810
# if the number of ICU days is less than zero make it zero
38113811
if self.icu_days < 0:
38123812
self.icu_days = 0

0 commit comments

Comments
 (0)