Skip to content

Commit be01175

Browse files
authored
Optimise hotspot when getting list of symptoms (#1593)
1 parent a384c90 commit be01175

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

src/tlo/methods/symptommanager.py

+2-9
Original file line numberDiff line numberDiff line change
@@ -530,16 +530,9 @@ def has_what(
530530
person_has = self.bsh.has(
531531
[person_id], disease_module.name, first=True, columns=sy_columns
532532
)
533-
return [s for s in self.symptom_names if person_has[f"sy_{s}"]]
533+
return [s for s in self.symptom_names if person_has[self.get_column_name_for_symptom(s)]]
534534
else:
535-
symptom_cols = df.loc[
536-
person_id, [f"sy_{s}" for s in self.symptom_names]
537-
]
538-
return (
539-
symptom_cols.index[symptom_cols > 0]
540-
.str.removeprefix("sy_")
541-
.to_list()
542-
)
535+
return [s for s in self.symptom_names if df.at[person_id, self.get_column_name_for_symptom(s)] > 0]
543536

544537
def have_what(self, person_ids: Sequence[int]):
545538
"""Find the set of symptoms for a list of person_ids.

0 commit comments

Comments
 (0)