Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve dataframe access in some hotspots #1592

Merged
merged 2 commits into from
Feb 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/tlo/methods/contraception.py
Original file line number Diff line number Diff line change
Expand Up @@ -1175,14 +1175,14 @@ def _get_appt_footprint(self, current_method: str):
def apply(self, person_id, squeeze_factor):
"""If the relevant consumable is available, do change in contraception and log it"""

person = self.sim.population.props.loc[person_id]
current_method = person.co_contraception

if not (person.is_alive and not person.is_pregnant):
df = self.sim.population.props
if not df.at[person_id, 'is_alive'] or df.at[person_id, 'is_pregnant']:
return

current_method = df.at[person_id, 'co_contraception']

# Record the date that Family Planning Appointment happened for this person
self.sim.population.props.at[person_id, "co_date_of_last_fp_appt"] = self.sim.date
df.at[person_id, "co_date_of_last_fp_appt"] = self.sim.date

# Measure weight, height and BP even if contraception not administrated
self.add_equipment({
Expand Down
3 changes: 1 addition & 2 deletions src/tlo/methods/symptommanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -757,8 +757,7 @@ def apply(self, population):
for symp in self.to_resolve.keys():
if date_today in self.to_resolve[symp]:
person_ids = self.to_resolve[symp].pop(date_today)
persons = df.loc[sorted(person_ids)]
person_ids_alive = persons[persons.is_alive].index
person_ids_alive = df.index[df.index.isin(person_ids) & df.is_alive]
self.module.change_symptom(
person_id=person_ids_alive,
add_or_remove='-',
Expand Down