starsimhub / starsim

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

Distribution validation #293

Closed daniel-klein closed 6 months ago

daniel-klein commented 8 months ago

Users shouldn't be able to substitute a Gaussian in place of a Bernoulli, etc. Need sufficient compatibility checking.

cliffckerr commented 7 months ago

For a Bernoulli distribution, it feels like the user shouldn't be able to choose any other distribution -- right?

robynstuart commented 7 months ago

I guess they could use the delta distribution (if we end up going with that). But that's likely a weird corner case

cliffckerr commented 6 months ago

Fixed, filter is now only available for Bernoulli distributions. Otherwise, the user could mess them up, but I don't think this is more of a risk than other things, and you get a reasonably clear error mesage:

import starsim as ss

pars = dict(
    diseases = dict(
        type = 'sir',
        p_death = ss.lognorm_ex(),
    ),
    networks = 'random'
)

sim = ss.Sim(pars)
sim.run()
sim.disp()

IndexError: arrays used as indices must be of integer (or boolean) type