starsimhub / starsim

Starsim disease modeling framework
http://starsim.org
MIT License
12 stars 8 forks source link

filtering on sim.people.age + another field using '&' fails #559

Closed RHull-IDM closed 3 months ago

RHull-IDM commented 3 months ago

This is a curious one. When the population changes due to births or deaths, filtering by sim.people.uid first in a sequence of conditions causes a shape mismatch ValueError. If the uid condition occurs after the other condition, it seems to work correctly.

import starsim as ss
import pandas as pd

ppl = ss.People(10000)
disease = ss.SIR()
pregnancy = ss.Pregnancy(pars={'fertility_rate': pd.read_csv(ss.root / 'tests/test_data/nigeria_asfr.csv')})
n_years = 3
sim = ss.Sim(dt=1 / 52, n_years=n_years, people=ppl, diseases=disease, demographics=pregnancy)
sim.run()

newborns = ((sim.people.age > 0) & (sim.people.uid > 10000)).uids # Works
newborns = ((sim.people.uid > 10000) & (sim.people.age > 0)).uids # Errors
devclinton commented 3 months ago

@RHull-IDM - Is this related to https://starsim-idm.slack.com/archives/C059G2HE57X/p1717649148257889 or https://github.com/starsimhub/starsim/issues/508?

cliffckerr commented 3 months ago

Closed by #561