Skip to content

Commit 39371e9

Browse files
committed
Test patient_normalise checks type and shape of data
1 parent c14de9a commit 39371e9

1 file changed

Lines changed: 16 additions & 4 deletions

File tree

tests/test_models.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,19 @@ def test_daily_min_string():
7373
),
7474
(
7575
[[-1, 2, 3], [4, 5, 6], [7, 8, 9]],
76-
[[0, 0.67, 1], [0.67, 0.83, 1], [0.78, 0.89, 1]],
76+
None,
7777
ValueError,
7878
),
79+
(
80+
'hello',
81+
None,
82+
TypeError,
83+
),
84+
(
85+
3,
86+
None,
87+
TypeError,
88+
),
7989
(
8090
[[1, 2, 3], [4, 5, 6], [7, 8, 9]],
8191
[[0.33, 0.67, 1], [0.67, 0.83, 1], [0.78, 0.89, 1]],
@@ -84,11 +94,13 @@ def test_daily_min_string():
8494
])
8595
def test_patient_normalise(test, expected, expect_raises):
8696
"""Test normalisation works for arrays of one and positive integers."""
87-
97+
if isinstance(test, list):
98+
test = np.array(test)
99+
88100
if expect_raises is not None:
89101
with pytest.raises(expect_raises):
90-
result = patient_normalise(np.array(test))
102+
result = patient_normalise(test)
91103
npt.assert_allclose(result, np.array(expected), rtol=1e-2, atol=1e-2)
92104
else:
93-
result = patient_normalise(np.array(test))
105+
result = patient_normalise(test)
94106
npt.assert_allclose(result, np.array(expected), rtol=1e-2, atol=1e-2)

0 commit comments

Comments
 (0)