22 lines
821 B
Python
22 lines
821 B
Python
import json
|
|
|
|
import pytest
|
|
|
|
pytest.importorskip('pymc')
|
|
pytest.importorskip('arviz')
|
|
|
|
from models.cacu.bayes_development.synthetic_diagnostics import evaluate
|
|
|
|
|
|
def test_nuts_synthetic_artifact(tmp_path):
|
|
path = tmp_path / 'diagnostics.json'
|
|
report = evaluate(path, n=80, draws=40, tune=40, seed=31)
|
|
assert json.loads(path.read_text()) == report
|
|
assert report['scope'] == 'synthetic_cross_sectional_prevalence_only'
|
|
assert report['current_pim_comparison']['status'] == 'not_comparable'
|
|
assert report['chains'] == 2 and report['divergences'] >= 0
|
|
for parameter in report['parameters'].values():
|
|
assert parameter['ess_bulk'] > 0 and parameter['ess_tail'] > 0
|
|
assert parameter['rhat'] > 0
|
|
assert parameter['error'] == pytest.approx(parameter['mean'] - parameter['truth'])
|