Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion rcpchgrowth/tests/test_reference_vectors_and_boundaries.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,14 @@ def test_every_reference_includes_its_lower_boundary_and_rejects_below_it(
),
(CDC, 2, 1.9999, BMI, MALE, "BMI below 2 years"),
(CDC, 3, 3.0001, HEAD_CIRCUMFERENCE, MALE, "head circumference above 3 years"),
(TRISOMY_21, 18.82, 18.8201, BMI, MALE, "BMI reference data"),
(
TRISOMY_21,
18.92,
math.nextafter(18.92, math.inf),
BMI,
MALE,
"BMI reference data",
),
(TRISOMY_21, 18, 18.0001, HEAD_CIRCUMFERENCE, MALE, "head circumference"),
(TRISOMY_21_AAP, 0.083333333, 0.0829, HEIGHT, MALE, "below 1 month"),
(TRISOMY_21_AAP, 2, 1.9999, BMI, MALE, "below 2 years"),
Expand Down
34 changes: 34 additions & 0 deletions rcpchgrowth/tests/test_trisomy_21_reference_boundaries.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import math

import pytest

from rcpchgrowth.constants import BMI, FEMALE, MALE, TRISOMY_21
from rcpchgrowth.global_functions import sds_for_measurement


@pytest.mark.parametrize("sex", [MALE, FEMALE])
@pytest.mark.parametrize("age", [18.83, 18.92])
def test_trisomy_21_bmi_accepts_final_source_ages(sex, age):
result = sds_for_measurement(
reference=TRISOMY_21,
age=age,
measurement_method=BMI,
observation_value=25.0,
sex=sex,
)

assert math.isfinite(result)


@pytest.mark.parametrize("sex", [MALE, FEMALE])
def test_trisomy_21_bmi_rejects_age_after_last_source_age(sex):
with pytest.raises(
LookupError, match=r"Trisomy BMI reference data does not exist > 18\.92 y\."
):
sds_for_measurement(
reference=TRISOMY_21,
age=math.nextafter(18.92, math.inf),
measurement_method=BMI,
observation_value=25.0,
sex=sex,
)
6 changes: 3 additions & 3 deletions rcpchgrowth/trisomy_21.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ def reference_data_absent(
if age > TWENTY_YEARS: # upper threshold of trisomy_21 data
return True, "Trisomy 21 reference data does not exist over the age of 20y."

elif measurement_method == BMI and age > 18.82:
return True, f"Trisomy BMI reference data does not exist > 18.82 y."
elif measurement_method == BMI and age > 18.92:
return True, "Trisomy BMI reference data does not exist > 18.92 y."

elif measurement_method == HEAD_CIRCUMFERENCE:
if age > EIGHTEEN_YEARS:
Expand Down Expand Up @@ -80,4 +80,4 @@ def select_reference_data_for_trisomy_21(measurement_method:str, sex:str):
return_value = trisomy_21_lms_array_for_measurement_and_sex(measurement_method=measurement_method, sex=sex, age=0.0)
except:
raise LookupError(f"No data for {measurement_method} in the {sex} Trisomy 21 dataset.")
return return_value
return return_value
Loading