Removed np.seed from tests and added retry decorator
This commit is contained in:
parent
9ebb521769
commit
8601e51adb
8 changed files with 10 additions and 16 deletions
|
|
@ -4,6 +4,7 @@ import typing
|
|||
import numpy as np
|
||||
import numpy.testing as npt
|
||||
import pytest
|
||||
from retry import retry
|
||||
|
||||
from cara.apps.calculator import model_generator
|
||||
from cara.apps.calculator.model_generator import _hours2timestring
|
||||
|
|
@ -11,8 +12,6 @@ from cara.apps.calculator.model_generator import minutes_since_midnight
|
|||
from cara import models
|
||||
from cara.monte_carlo.data import expiration_distributions
|
||||
|
||||
# TODO: seed better the random number generators
|
||||
np.random.seed(2000)
|
||||
|
||||
def test_model_from_dict(baseline_form_data):
|
||||
form = model_generator.FormData.from_dict(baseline_form_data)
|
||||
|
|
@ -25,6 +24,7 @@ def test_model_from_dict_invalid(baseline_form_data):
|
|||
model_generator.FormData.from_dict(baseline_form_data)
|
||||
|
||||
|
||||
@retry(tries=10)
|
||||
@pytest.mark.parametrize(
|
||||
["mask_type"],
|
||||
[
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ async def test_404(http_server_client):
|
|||
assert resp.code == 404
|
||||
|
||||
|
||||
@retry()
|
||||
@retry(tries=10)
|
||||
class TestBasicApp(tornado.testing.AsyncHTTPTestCase):
|
||||
def get_app(self):
|
||||
return cara.apps.calculator.make_app()
|
||||
|
|
@ -72,7 +72,7 @@ class TestBasicApp(tornado.testing.AsyncHTTPTestCase):
|
|||
assert 'expected number of new cases is' in response.body.decode()
|
||||
|
||||
|
||||
@retry()
|
||||
@retry(tries=10)
|
||||
class TestCernApp(tornado.testing.AsyncHTTPTestCase):
|
||||
def get_app(self):
|
||||
cern_theme = Path(cara.apps.calculator.__file__).parent.parent / 'themes' / 'cern'
|
||||
|
|
@ -85,7 +85,7 @@ class TestCernApp(tornado.testing.AsyncHTTPTestCase):
|
|||
assert 'expected number of new cases is' in response.body.decode()
|
||||
|
||||
|
||||
retry()
|
||||
retry(tries=10)
|
||||
class TestOpenApp(tornado.testing.AsyncHTTPTestCase):
|
||||
def get_app(self):
|
||||
return cara.apps.calculator.make_app(calculator_prefix="/mycalc")
|
||||
|
|
|
|||
|
|
@ -9,8 +9,6 @@ from cara.apps.calculator.model_generator import build_expiration
|
|||
from cara.monte_carlo.data import short_range_expiration_distributions,\
|
||||
expiration_distributions, short_range_distances, activity_distributions
|
||||
|
||||
# TODO: seed better the random number generators
|
||||
np.random.seed(2000)
|
||||
SAMPLE_SIZE = 250_000
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import re
|
|||
import numpy as np
|
||||
import numpy.testing as npt
|
||||
import pytest
|
||||
from retry import retry
|
||||
|
||||
from cara import models
|
||||
from cara.monte_carlo.data import expiration_distribution
|
||||
|
|
@ -41,6 +42,7 @@ def test_multiple():
|
|||
npt.assert_almost_equal(aerosol_expected, e.aerosols(mask))
|
||||
|
||||
|
||||
@retry(tries=10)
|
||||
# expected values obtained from analytical formulas
|
||||
@pytest.mark.parametrize(
|
||||
"BLO_weights, expected_aerosols",
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ from scipy.integrate import quad
|
|||
from scipy.special import erf
|
||||
import numpy.testing as npt
|
||||
import pytest
|
||||
from retry import retry
|
||||
|
||||
import cara.monte_carlo as mc
|
||||
from cara import models,data
|
||||
|
|
@ -16,8 +17,6 @@ from cara.monte_carlo.data import (expiration_distributions,
|
|||
expiration_BLO_factors,short_range_expiration_distributions,
|
||||
short_range_distances,virus_distributions,activity_distributions)
|
||||
|
||||
# TODO: seed better the random number generators
|
||||
np.random.seed(2000)
|
||||
SAMPLE_SIZE = 1_000_000
|
||||
TOLERANCE = 0.04
|
||||
|
||||
|
|
@ -655,6 +654,7 @@ def test_longrange_concentration(time,c_model,simple_c_model):
|
|||
)
|
||||
|
||||
|
||||
@retry(tries=10)
|
||||
@pytest.mark.parametrize(
|
||||
"time", [10, 10.7, 11., 12.5, 14.75, 14.9, 17]
|
||||
)
|
||||
|
|
|
|||
|
|
@ -8,8 +8,6 @@ from cara import models,data
|
|||
from cara.monte_carlo.data import activity_distributions, virus_distributions, expiration_distributions, infectious_dose_distribution, viable_to_RNA_ratio_distribution
|
||||
from cara.apps.calculator.model_generator import build_expiration
|
||||
|
||||
# TODO: seed better the random number generators
|
||||
np.random.seed(2000)
|
||||
SAMPLE_SIZE = 500_000
|
||||
TOLERANCE = 0.05
|
||||
|
||||
|
|
@ -336,6 +334,7 @@ def test_report_models(mc_model, expected_pi, expected_new_cases,
|
|||
expected_ER, rtol=TOLERANCE)
|
||||
|
||||
|
||||
@retry(tries=10)
|
||||
@pytest.mark.parametrize(
|
||||
"mask_type, month, expected_pi, expected_dose, expected_ER",
|
||||
[
|
||||
|
|
|
|||
|
|
@ -4,8 +4,6 @@ import pytest
|
|||
|
||||
from cara.monte_carlo.data import activity_distributions, virus_distributions
|
||||
|
||||
# TODO: seed better the random number generators
|
||||
np.random.seed(2000)
|
||||
|
||||
|
||||
# mean & std deviations from https://doi.org/10.1101/2021.10.14.21264988 (Table 3)
|
||||
|
|
|
|||
|
|
@ -4,9 +4,6 @@ import pytest
|
|||
|
||||
from cara.monte_carlo import sampleable
|
||||
|
||||
# TODO: seed better the random number generators
|
||||
np.random.seed(2000)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"mean, std",[
|
||||
|
|
|
|||
Loading…
Reference in a new issue