-
Notifications
You must be signed in to change notification settings - Fork 7
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
Outcome of test in tests_newborn_outcomes
depends on RNG state
#274
Comments
tests_newborn_outcomes
depends on random number generator statetests_newborn_outcomes
depends on RNG state
Please take a look at this @joehcollins |
Hi @matt-graham @tamuri - thanks for catching this. Thought i'd forced I've made changes in a separate branch, including the change to |
Thanks, Joe. If you let Matt know the branch, he'll merge your changes into this PR. |
Perfect just running the test file once more |
@matt-graham - everything seems to be working ok now. The branch is jcollins_rng_fix_may2021. Thanks! |
Thanks @joehcollins for the quick response and fix. I've merged your branch into my branch for #267. Once that gets merged we can close this issue too. |
While reviewing #267 @asif picked up a use of the global NumPy random number generator interface
numpy.random
rather than the local seededRandomState
innewborn_outcomes
TLOmodel/src/tlo/methods/newborn_outcomes.py
Lines 471 to 472 in 82a0c3b
After changing this to
the
test_newborn_hsi_applies_risk_of_complications_and_delivers_treatment_to_facility_births
test intest_newborn_outcomes
fails at this lineTLOmodel/tests/test_newborn_outcomes.py
Line 433 in 82a0c3b
From what I can tell from digging through the code in
newborn_outcomes
, this property is set inTLOmodel/src/tlo/methods/newborn_outcomes.py
Lines 521 to 527 in 82a0c3b
based on the outcome of a call to
NewbornOutcomes.eval
which uses a linear model to compute the probability for a Bernoulli outcome and then uses the pseudo-random number generator (RNG) to compute the outcome. This means that the value set for thenb_early_onset_neonatal_sepsis
is dependent on the state of the RNG which would explain why this test fails when updating to use the module level RNG.It seems like this might potentially also be related to this previous PR #260
@tamuri @tbhallett @joehcollins - tagging you all as you are all listed as authors on the commit which added the test
The text was updated successfully, but these errors were encountered: