1+ """Tests for statistics functions within the Model layer."""
2+
3+ import numpy as np
4+ import numpy .testing as npt
5+ import pytest
6+
7+ from inflammation .models import daily_mean , daily_max , daily_min
8+
9+ @pytest .mark .parametrize (
10+ "test, expected" ,
11+ [
12+ ([[0 ,0 ],[0 ,0 ],[0 ,0 ]],[0 ,0 ]),
13+ ([[0 , 0 ],[0 , 0 ],[0 , 0 ]], [0 , 0 ]),
14+ ([[- 1 , - 1 ],[- 1 , - 1 ],[- 1 , - 1 ]],[- 1 , - 1 ]),
15+ ([[1 , 2 ],[3 , 4 ],[5 , 6 ]],[3 , 4 ]),
16+ ([[1 , 2 ],[3 , 4 ],[5 , 6 ]], [6 , 7 ])
17+ ]
18+ )
19+ #not sure why pytest seems to be required here. error says it should be test but doesn't seem to work
20+ def pytest_daily_mean_zeros ():
21+ """Test that mean function works for an array of zeros."""
22+
23+ test_input = np .array ([[0 , 0 ],
24+ [0 , 0 ],
25+ [0 , 0 ]])
26+ test_result = np .array ([0 , 0 ])
27+
28+ # Need to use Numpy testing functions to compare arrays
29+ npt .assert_array_equal (daily_mean (test_input ), test_result )
30+ #------------------------------------------
31+ def test_daily_mean_negatives ():
32+ """Test that mean function works for an array of zeros."""
33+
34+ test_input = np .array ([[- 1 , - 1 ],
35+ [- 1 , - 1 ],
36+ [- 1 , - 1 ]])
37+ test_result = np .array ([- 1 , - 1 ])
38+
39+ # Need to use Numpy testing functions to compare arrays
40+ npt .assert_array_equal (daily_mean (test_input ), test_result )
41+ #------------------------------------------
42+
43+ def test_daily_mean_integers ():
44+ """Test that mean function works for an array of positive integers."""
45+
46+ test_input = np .array ([[1 , 2 ],
47+ [3 , 4 ],
48+ [5 , 6 ]])
49+ test_result = np .array ([3 , 4 ])
50+
51+ # Need to use Numpy testing functions to compare arrays
52+ npt .assert_array_equal (daily_mean (test_input ), test_result )
53+
54+ def test_daily_mean ():
55+ test_input = np .array ([[1 , 2 ],
56+ [3 , 4 ],
57+ [5 , 6 ]])
58+ test_result = np .array ([3 , 4 ])
59+
60+ npt .assert_array_equal (daily_mean (test_input ), test_result )
61+ """
62+ def test_daily_mean_string():
63+ test_input = np.array([["this is something incorrect", 2],
64+ [3, 4],
65+ [5, 6]])
66+ test_result = np.array([3, 4])
67+
68+ npt.assert_array_equal(daily_mean(test_input), test_result)
69+ """
70+
71+
72+ """
73+ def test_daily_min_string():
74+ #test for typeerror when passing strings
75+
76+ #with pytest.raises(TypeError):
77+ # error_expected = daily_min([["one", "two"],["3","4"]])
78+ """
79+
80+ #this is an update test
81+
82+ """Tests for the Patient model - class/file in this folder
83+
84+ from inflammation.models import Patient
85+
86+ def test_create_patient():
87+
88+ name = 'Alice'
89+ p = Patient(name=name)
90+
91+ assert p.name == name
92+ """
0 commit comments