44 lines
1.2 KiB
Python
44 lines
1.2 KiB
Python
"""Screening calibration: sensitivity and the two sample-size gates."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import pytest
|
|
from typer.testing import CliRunner
|
|
|
|
from cli.prisma import app
|
|
from prisma.calibrate import cleared, sensitivity, sized
|
|
|
|
runner = CliRunner()
|
|
|
|
|
|
def test_sensitivity_counts_include_and_uncertain():
|
|
assert (
|
|
sensitivity(
|
|
["include", "exclude", "uncertain"],
|
|
["uncertain", "exclude", "exclude"],
|
|
)
|
|
== 0.5
|
|
)
|
|
|
|
|
|
def test_sensitivity_rejects_a_bad_comparison():
|
|
with pytest.raises(ValueError):
|
|
sensitivity(["include"], ["include", "exclude"])
|
|
with pytest.raises(ValueError):
|
|
sensitivity(["exclude"], ["exclude"])
|
|
|
|
|
|
def test_size_and_clearance_gates():
|
|
assert sized(200, "title_abstract") is True
|
|
assert sized(199, "title_abstract") is False
|
|
assert sized(50, "full_text") is True
|
|
assert sized(49, "full_text") is False
|
|
assert cleared(0.95, 200, 50) is True
|
|
assert cleared(0.949, 200, 50) is False
|
|
assert cleared(1.0, 199, 50) is False
|
|
|
|
|
|
def test_calibrate_command_is_registered():
|
|
result = runner.invoke(app, ["calibrate", "--help"])
|
|
assert result.exit_code == 0
|