washingtonpost / elex-live-model

a model to generate estimates of the number of outstanding votes on an election night based on the current results of the race
48 stars 5 forks source link

ELEX-2402-random-seed-model-OLD #60

Closed rishasurana closed 1 year ago

rishasurana commented 1 year ago

IGNORE

Description

Original error description: In ‘test_redo.py’ and ‘test_vary_params.py’ the unit tests that use the ‘frac_within_pi’ and ‘mean_pi_length’ are currently commented out. That is because those tests rely on some of the randomness in the model (computes CI’s) so won’t be the same value run to run. We need to set a model seed that only affects the unit tests - so those values are the same each time.

New error description: The error appears to not be caused by the randomness of the model. This is because the error only occurs during the ‘mean_pi_length’ calculation when the result (on either side, rounded to the second decimal) ends in a 5. The python .roundfunction uses "banker's rounding" which is causing the following issues.

ERROR: assert 0.3 == 0.29 <--> 0.296 == 0.295 ERROR: assert 0.26 == 0.25 <--> assert 0.255 == 0.256 ERROR: assert 0.557 == 0.558 <--> 0.56 == 0.558

To resolve this error, a corresponding PR is opened in elex-live-model-testbed to update the tests. This PR will update math_utils.py.

Jira Ticket

https://arcpublishing.atlassian.net/browse/ELEX-2402