Skip to content

Commit 50a90fd

Browse files
committed
this
1 parent 17f03cb commit 50a90fd

3 files changed

Lines changed: 23 additions & 1 deletion

File tree

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
strategy:
99
matrix:
1010
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
11-
python-version: ["3.12"]# this needs to be part of the reqiurements I think, e
11+
python-version: ["3.12"]# this needs to be part of the requirements I think, e
1212

1313
# Here we add the reference to the os matrix values
1414
runs-on: ${{ matrix.os }}

inflammation/models.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,8 @@ def daily_min(data):
3232
"""Calculate the daily min of a 2d inflammation data array."""
3333
return np.min(data, axis=0)
3434

35+
def patient_normalise(data):
36+
"""Normalise patient data from a 2D inflammation data array."""
37+
max = np.max(data, axis=0)
38+
return data / max[:, np.newaxis]
39+

tests/test_models.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import pytest
66

77
from inflammation.models import daily_mean, daily_max, daily_min
8+
from inflammation.models import patient_normalise
9+
810

911
@pytest.mark.parametrize(
1012
"test, expected",
@@ -77,6 +79,21 @@ def test_daily_min_string():
7779
# error_expected = daily_min([["one", "two"],["3","4"]])
7880
"""
7981

82+
83+
84+
@pytest.mark.parametrize(
85+
"test, expected",
86+
[
87+
([[1, 2, 3], [4, 5, 6], [7, 8, 9]], [[0.33, 0.67, 1], [0.67, 0.83, 1], [0.78, 0.89, 1]])
88+
])
89+
def test_patient_normalise(test, expected):
90+
"""Test normalisation works for arrays of one and positive integers.
91+
Test with a relative and absolute tolerance of 0.01."""
92+
93+
result = patient_normalise(np.array(test))
94+
npt.assert_allclose(result, np.array(expected), rtol=1e-2, atol=1e-2)
95+
96+
8097
#this is an update test
8198

8299
"""Tests for the Patient model - class/file in this folder

0 commit comments

Comments
 (0)