22
33import numpy as np
44import 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
810def 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