Files
models/tests/test_curves.py
T
alberto d8445fcabf Cleanup of the TEA parity work: no prose in code, no hacks, everything in its place
1. No prose in code
- Remove parity-added comments and docstrings from TEA jobs, analysis and
  scoring helpers, execution, definitions, and tests. Keep base prose and
  Ruff and type-checker directives.

2. No hacks, no glued code
- Delegate both association cohort queries to persistance.eeg. Keep the
  predictor mapping and DataFrame shaping in the job, sharing biomarker
  codes and EEG study IDs with Core. Preserve column names and order, row
  selection, score filtering, and earliest fitting study.
- Use the existing MODELS registry for curve scoring in place of CURVES.
  Keep GOLD because the generic score job reads it.
- Catch lookup, database, and validation failures when loading a preview
  pipeline, preserving the existing warning. Keep execution-boundary
  exception handling for submitted tasks, telemetry and shutdown.
- Name the association test for the missing-champion case. Preserve its
  assertion and the other test assertions.

3. Everything in its place
- Keep SQL in Persistance, cohort shaping in models, and tests in their
  existing testpaths. Keep the association fits together with their
  shared design and result machinery.
2026-11-30 13:41:49 -06:00

25 lines
738 B
Python

import pytest
from models.tea.eeg import curves
def test_centile_interpolation_preserves_scoring():
baseline = {
"kind": "curves",
"curve": {
"age_months": [16, 36],
"p5": [1, 3],
"p25": [2, 4],
"median": [3, 5],
"p75": [5, 7],
"p95": [7, 9],
},
}
assert curves.centiles(baseline, 24) == pytest.approx(
{"p5": 2, "p25": 3, "median": 4, "p75": 6, "p95": 8}
)
for value, z, outside in ((0, -3.29, -1), (3, -0.8225, 0), (6, 0.8225, 0), (10, 2.4675, 1)):
assert curves.score(baseline, value, 24) == pytest.approx(
{"z": z, "outside": outside, "p5": 2, "median": 4, "p95": 8}, rel=1e-9
)