1
1
import pytest
2
2
import pandas as pd
3
-
3
+ import numpy as np
4
4
5
5
from app import (projection_admits , alt )
6
6
from penn_chime .models import sir , sim_sir , sim_sir_df , Parameters
@@ -81,12 +81,18 @@ def test_sir():
81
81
"""
82
82
Someone who is good at testing, help
83
83
"""
84
- assert sir (100 , 1 , 0 , 0.2 , 0.5 , 1 ) == (
84
+ sir_test = sir (100 , 1 , 0 , 0.2 , 0.5 , 1 )
85
+ assert sir_test == (
85
86
0.7920792079207921 ,
86
87
0.20297029702970298 ,
87
88
0.0049504950495049506 ,
88
89
), "This contrived example should work"
89
90
91
+ assert isinstance (sir_test , tuple )
92
+ for v in sir_test :
93
+ assert isinstance (v , float )
94
+ assert v >= 0
95
+
90
96
# Certain things should *not* work
91
97
with pytest .raises (TypeError ) as error :
92
98
sir ("S" , 1 , 0 , 0.2 , 0.5 , 1 )
@@ -121,7 +127,8 @@ def test_sim_sir():
121
127
"""
122
128
Rounding to move fast past decimal place issues
123
129
"""
124
- s , i , r = sim_sir (5 , 6 , 7 , 0.1 , 0.1 , 40 )
130
+ sim_sir_test = sim_sir (5 , 6 , 7 , 0.1 , 0.1 , 40 )
131
+ s , i , r = sim_sir_test
125
132
126
133
assert round (s [0 ], 0 ) == 5
127
134
assert round (i [0 ], 2 ) == 6
@@ -130,6 +137,11 @@ def test_sim_sir():
130
137
assert round (i [- 1 ], 2 ) == 0.18
131
138
assert round (r [- 1 ], 2 ) == 17.82
132
139
140
+ assert isinstance (sim_sir_test , tuple )
141
+ for v in sim_sir_test :
142
+ assert isinstance (v , np .ndarray )
143
+
144
+
133
145
134
146
def test_sim_sir_df ():
135
147
"""
@@ -147,25 +159,6 @@ def test_sim_sir_df():
147
159
assert round (last [2 ], 2 ) == 17.82
148
160
149
161
150
- #ef test_initial_conditions():
151
- # """
152
- # Note: For the rates (ie hosp_rate) - just change the value, leave the "100" alone.
153
- # Easier to change whole numbers than decimals.
154
- # """
155
- # assert current_hosp == known_cases
156
- # assert doubling_time == 6
157
- # assert relative_contact_rate == 0
158
- # assert hosp_rate == 5 / 100
159
- # assert icu_rate == 2 / 100
160
- # assert vent_rate == 1 / 100
161
- # assert hosp_los == 7
162
- # assert icu_los == 9
163
- # assert vent_los == 10
164
- # assert market_share == 15 / 100
165
- # assert S == S_default
166
- # assert initial_infections == known_infections
167
-
168
-
169
162
def test_new_admissions_chart ():
170
163
chart = new_admissions_chart (alt , projection_admits , 60 - 10 )
171
164
assert isinstance (chart , alt .Chart )
0 commit comments