Skip to content

Update the correct column if HIV HSI event didn't run#1835

Merged
tamuri merged 2 commits intomasterfrom
tamuri/fix-hiv-never-ran
Feb 26, 2026
Merged

Update the correct column if HIV HSI event didn't run#1835
tamuri merged 2 commits intomasterfrom
tamuri/fix-hiv-never-ran

Conversation

@tamuri
Copy link
Collaborator

@tamuri tamuri commented Feb 25, 2026

This was a nasty bug to track down!

While profiling, I noticed the population dataframe had grown from 494 to 567 columns during the simulation. New columns were being added as the simulation ran. The column names were property, which is a built-in Python keyword. No hint as to where it was coming from. Each of these columns contained a single False for one person, all the rest nan. After a lot of laborious stepping through code, traced issue to changes introduced in #1616

property is a Python keyword (most commonly used as the @property decorator). The variable property set in apply() is not included in never_ran(). As a result, each time never_ran() is called, a new column is created.

I've made following changes:

  • Renamed the variable to prep_column to avoid shadowing the built-in property
  • Moved the column name logic into a function so it can be used in both apply() and never_ran()

@tamuri tamuri requested review from tbhallett and tdm32 February 25, 2026 22:41
@tbhallett
Copy link
Collaborator

Wow, did not expect that to happen. Thanks for finding and fixing.

@tamuri tamuri merged commit 4ca6a04 into master Feb 26, 2026
69 checks passed
@tamuri tamuri deleted the tamuri/fix-hiv-never-ran branch February 26, 2026 09:19
@tdm32
Copy link
Collaborator

tdm32 commented Feb 26, 2026

Thanks Asif for spotting and fixing that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants