Skip to content

Commit b6d1a1a

Browse files
committed
Add initial test cases for daily_max() and daily_min()
1 parent d213499 commit b6d1a1a

2 files changed

Lines changed: 83 additions & 2 deletions

File tree

requirements.txt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,37 @@
1+
astroid==3.3.10
2+
asttokens==3.0.0
13
contourpy==1.3.2
24
cycler==0.12.1
5+
decorator==5.2.1
6+
dill==0.4.0
7+
executing==2.2.0
38
fonttools==4.58.5
9+
iniconfig==2.1.0
10+
ipython==9.4.0
11+
ipython_pygments_lexers==1.1.1
12+
isort==6.0.1
13+
jedi==0.19.2
414
kiwisolver==1.4.8
515
matplotlib==3.10.3
16+
matplotlib-inline==0.1.7
17+
mccabe==0.7.0
618
numpy==2.3.1
719
packaging==25.0
20+
parso==0.8.4
21+
pexpect==4.9.0
822
pillow==11.3.0
23+
platformdirs==4.3.8
24+
pluggy==1.6.0
25+
prompt_toolkit==3.0.51
26+
ptyprocess==0.7.0
27+
pure_eval==0.2.3
28+
Pygments==2.19.2
29+
pylint==3.3.7
930
pyparsing==3.2.3
31+
pytest==8.4.1
1032
python-dateutil==2.9.0.post0
1133
six==1.17.0
34+
stack-data==0.6.3
35+
tomlkit==0.13.3
36+
traitlets==5.14.3
37+
wcwidth==0.2.13

tests/test_models.py

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22

33
import numpy as np
44
import numpy.testing as npt
5+
import pytest
6+
7+
from inflammation.models import daily_mean, daily_max, daily_min
58

6-
from inflammation.models import daily_mean
79

810
def test_daily_mean_zeros():
911
"""Test that mean function works for an array of zeros."""
1012

11-
1213
test_input = np.array([[0, 0],
1314
[0, 0],
1415
[0, 0]])
@@ -29,3 +30,57 @@ def test_daily_mean_integers():
2930
# Need to use Numpy testing functions to compare arrays
3031
npt.assert_array_equal(daily_mean(test_input), test_result)
3132

33+
34+
def test_daily_max_integers():
35+
"""Test that max function works for an array of positive integers."""
36+
37+
test_input = np.array([[1, 2],
38+
[3, 4],
39+
[5, 6]])
40+
test_result = np.array([5, 6])
41+
42+
# Need to use Numpy testing functions to compare arrays
43+
npt.assert_array_equal(daily_max(test_input), test_result) # This should be daily_max
44+
45+
46+
def test_daily_max_zeros():
47+
"""Test that min function works for an array of zeros."""
48+
49+
test_input = np.array([[0, 0],
50+
[0, 0],
51+
[0, 0]])
52+
test_result = np.array([0, 0])
53+
54+
# Need to use Numpy testing functions to compare arrays
55+
npt.assert_array_equal(daily_max(test_input), test_result) # This should be daily_min
56+
57+
58+
def test_daily_min_integers():
59+
"""Test that min function works for an array of positive integers."""
60+
61+
test_input = np.array([[1, 2],
62+
[3, 4],
63+
[5, 6]])
64+
test_result = np.array([1, 2])
65+
66+
# Need to use Numpy testing functions to compare arrays
67+
npt.assert_array_equal(daily_min(test_input), test_result) # This should be daily_min
68+
69+
70+
def test_daily_min_zeros():
71+
"""Test that min function works for an array of zeros."""
72+
73+
test_input = np.array([[0, 0],
74+
[0, 0],
75+
[0, 0]])
76+
test_result = np.array([0, 0])
77+
78+
# Need to use Numpy testing functions to compare arrays
79+
npt.assert_array_equal(daily_min(test_input), test_result) # This should be daily_min
80+
81+
82+
def test_daily_min_string():
83+
"""Test for TypeError when passing strings"""
84+
85+
with pytest.raises(TypeError):
86+
error_expected = daily_min([['Hello', 'there'], ['General', 'Kenobi']])

0 commit comments

Comments
 (0)