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

Updating a Dist with a function fails silently #597

Closed
cliffckerr opened this issue Aug 20, 2024 · 2 comments
Closed

Updating a Dist with a function fails silently #597

cliffckerr opened this issue Aug 20, 2024 · 2 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@cliffckerr
Copy link
Contributor

cliffckerr commented Aug 20, 2024

import starsim as ss

p = 0.123

def prob_func(module=None, sim=None, size=None):
    return p

d1 = ss.HIV(init_prev=p) # fine
d2 = ss.HIV(init_prev=ss.bernoulli(p)) # fine
d3 = ss.HIV(init_prev=prob_func) # NOT FINE
d4 = ss.HIV(init_prev=ss.bernoulli(prob_func)) # fine
di = [d1, d2, d3, d4]

sims = [ss.Sim(diseases=d) for d in di]
sims = ss.parallel(sims).sims
for s in sims:
    print(s.diseases.hiv.pars.init_prev)

gives

ss.bernoulli(pars_hiv_init_prev, pars={'p': 0.123}) # fine
ss.bernoulli(pars_hiv_init_prev, pars={'p': 0.123}) # fine
ss.bernoulli(pars_hiv_init_prev, pars={'p': 0.05}) # WRONG, no error
ss.bernoulli(pars_hiv_init_prev, pars={'p': <function prob_func at 0x72d70041afc0>}) # fine

Should either just work, or raise an exception

@cliffckerr cliffckerr added the bug Something isn't working label Aug 20, 2024
@cliffckerr cliffckerr self-assigned this Aug 20, 2024
@cliffckerr cliffckerr changed the title Updating a dist with a function fails silently Updating a Dist with a function fails silently Aug 20, 2024
@cliffckerr cliffckerr added this to the Backlog milestone Sep 9, 2024
@cliffckerr
Copy link
Contributor Author

Now raises an exception, but should work

@cliffckerr cliffckerr modified the milestones: Backlog, Version 2.2 Nov 8, 2024
@cliffckerr
Copy link
Contributor Author

Closed by #778

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant