[c330f8]: / tests / test_utils.py

Download this file

13 lines (10 with data), 640 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
import pytest
from src.cvd_risk_scores.modules import utils
@pytest.mark.parametrize('n_sub', [100, 1000])
@pytest.mark.parametrize('population_stats', [utils.FraminghamPopulationStatistics])
def test_generate_framingham(n_sub, population_stats, rng):
pop_stats = population_stats()
population = utils.generate_population(n_sub, pop_stats, random_state=rng)
assert population.shape[0] == n_sub
assert population.query("sex == 'female'").shape[0] == round(n_sub * pop_stats.stats.get("female").get("prop"))
assert population.query("sex == 'male'").shape[0] == round(n_sub * pop_stats.stats.get("male").get("prop"))