copd-model-c / training /tests /test_minimum_period_between_exacerbations.py
IamGrooooot's picture
Initial release: 72-hour COPD exacerbation prediction model
e69d4e4
"""Unit tests for the minimum_period_between_exacerbations function."""
import copd
import pandas as pd
import pytest
@pytest.mark.parametrize("input_values,expected_output",
[(pd.DataFrame({'DaysSinceLastExac': [-1]}), 0),
(pd.DataFrame({'DaysSinceLastExac': [7]}), 1),
(pd.DataFrame({'DaysSinceLastExac': [14]}), 1),
(pd.DataFrame({'DaysSinceLastExac': [20]}), 0)])
def test_threshold_equals_default(input_values, expected_output):
"""Test output for a variety of input values.
Test cases cover:
1. No previous exacerbation
2. Very recent exac
3. Exac on the threshold value (should count as too recent)
4. Previous non-recent exac
for the default threshold of 14 days
"""
assert copd.minimum_period_between_exacerbations(input_values) == expected_output
@pytest.mark.parametrize("input_values,expected_output",
[(pd.DataFrame({'DaysSinceLastExac': [-1]}), 0),
(pd.DataFrame({'DaysSinceLastExac': [6]}), 1),
(pd.DataFrame({'DaysSinceLastExac': [7]}), 1),
(pd.DataFrame({'DaysSinceLastExac': [14]}), 0)])
def test_threshold_equals_seven(input_values, expected_output):
"""Test output for a variety of input values.
Test cases cover:
1. No previous exacerbation
2. Very recent exac
3. Exac on the threshold value (should count as too recent)
4. Previous non-recent exac
for a threshold of 7 days.
"""
assert copd.minimum_period_between_exacerbations(
input_values, minimum_days=7) == expected_output