Skip to content

Commit

Permalink
Tested and fixed EULA code.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Bloedow committed Aug 20, 2024
1 parent 54841b6 commit 0e57c11
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions nnmm/mods/mortality.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ def init( model ):
# Find index of first value after eula_age
split_index = np.searchsorted(model.population.age, eula_age)
# Get list of indices we would EULA-ify
dod_filtered = model.population.dod[0:split_index]
# If pop is age order, lowest to highest, we keep the "left chunk" and eula-ify the middle chunk
dod_filtered = model.population.dod[split_index:model.population.count]
# Convert these all to "simulation year of death"
death_years = dod_filtered // 365
# Now invoke function in Population class to calculate the expected deaths by simulation year
Expand Down Expand Up @@ -88,7 +89,11 @@ def do_non_disease_deaths(model, tick):
year = tick // 365
if model.population.expected_new_deaths_per_year is not None:
for nodeid in range(len(model.population.expected_new_deaths_per_year)):
model.nodes.population[nodeid,tick+1] -= (model.population.expected_new_deaths_per_year[nodeid][year]/365)
# converting yearly number to daily basically sucks
deaths = (model.population.expected_new_deaths_per_year[nodeid][year]/365)
model.nodes.population[nodeid,tick+1] -= deaths
# Reporting only
model.nodes.deaths[nodeid,year] += deaths

pq = model.nddq
while len(pq) > 0 and pq.peekv() <= tick:
Expand Down
2 changes: 1 addition & 1 deletion src/idmlaser/numpynumba/population.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ def expected_deaths_over_sim(self, death_years, split_index, sim_years=10):
death_years[death_years > sim_years] = sim_years # Cap deaths at years-1

# Initialize the expected_new_deaths array
nodeids_filtered = self.nodeid[0:split_index]
nodeids_filtered = self.nodeid[split_index:self.count]
unique_nodeids = np.unique(nodeids_filtered) # slow way of calculating node count
nodeid_indices = {nodeid: i for i, nodeid in enumerate(unique_nodeids)}
self.expected_new_deaths_per_year = np.zeros((len(unique_nodeids), sim_years+1), dtype=int)
Expand Down

0 comments on commit 0e57c11

Please sign in to comment.