3
3
4
4
5
5
from app import (projection_admits , alt )
6
- from penn_chime .models import sir , sim_sir , sim_sir_df
6
+ from penn_chime .models import sir , sim_sir , sim_sir_df , Parameters
7
7
from penn_chime .presentation import display_header , new_admissions_chart
8
8
from penn_chime .settings import DEFAULTS
9
+ from penn_chime .defaults import RateLos
9
10
10
11
11
12
# set up
@@ -67,7 +68,7 @@ def test_header_fail():
67
68
st .cleanup ()
68
69
69
70
70
- def test_defaultS_repr ():
71
+ def test_defaults_repr ():
71
72
"""
72
73
Test DEFAULTS.repr
73
74
"""
@@ -87,29 +88,29 @@ def test_sir():
87
88
), "This contrived example should work"
88
89
89
90
# Certain things should *not* work
90
- with pytest .raises (TypeError ) as E :
91
+ with pytest .raises (TypeError ) as error :
91
92
sir ("S" , 1 , 0 , 0.2 , 0.5 , 1 )
92
- assert str (E .value ) == "can't multiply sequence by non-int of type 'float'"
93
+ assert str (error .value ) == "can't multiply sequence by non-int of type 'float'"
93
94
94
- with pytest .raises (TypeError ) as E :
95
+ with pytest .raises (TypeError ) as error :
95
96
sir (100 , "I" , 0 , 0.2 , 0.5 , 1 )
96
- assert str (E .value ) == "can't multiply sequence by non-int of type 'float'"
97
+ assert str (error .value ) == "can't multiply sequence by non-int of type 'float'"
97
98
98
- with pytest .raises (TypeError ) as E :
99
+ with pytest .raises (TypeError ) as error :
99
100
sir (100 , 1 , "R" , 0.2 , 0.5 , 1 )
100
- assert str (E .value ) == "unsupported operand type(s) for +: 'float' and 'str'"
101
+ assert str (error .value ) == "unsupported operand type(s) for +: 'float' and 'str'"
101
102
102
- with pytest .raises (TypeError ) as E :
103
+ with pytest .raises (TypeError ) as error :
103
104
sir (100 , 1 , 0 , "beta" , 0.5 , 1 )
104
- assert str (E .value ) == "bad operand type for unary -: 'str'"
105
+ assert str (error .value ) == "bad operand type for unary -: 'str'"
105
106
106
- with pytest .raises (TypeError ) as E :
107
+ with pytest .raises (TypeError ) as error :
107
108
sir (100 , 1 , 0 , 0.2 , "gamma" , 1 )
108
- assert str (E .value ) == "unsupported operand type(s) for -: 'float' and 'str'"
109
+ assert str (error .value ) == "unsupported operand type(s) for -: 'float' and 'str'"
109
110
110
- with pytest .raises (TypeError ) as E :
111
+ with pytest .raises (TypeError ) as error :
111
112
sir (100 , 1 , 0 , 0.2 , 0.5 , "N" )
112
- assert str (E .value ) == "unsupported operand type(s) for /: 'str' and 'float'"
113
+ assert str (error .value ) == "unsupported operand type(s) for /: 'str' and 'float'"
113
114
114
115
# Zeros across the board should fail
115
116
with pytest .raises (ZeroDivisionError ):
@@ -120,7 +121,7 @@ def test_sim_sir():
120
121
"""
121
122
Rounding to move fast past decimal place issues
122
123
"""
123
- s ,i , r = sim_sir (5 , 6 , 7 , 0.1 , 0.1 , 40 )
124
+ s , i , r = sim_sir (5 , 6 , 7 , 0.1 , 0.1 , 40 )
124
125
125
126
assert round (s [0 ], 0 ) == 5
126
127
assert round (i [0 ], 2 ) == 6
@@ -167,7 +168,7 @@ def test_sim_sir_df():
167
168
168
169
def test_new_admissions_chart ():
169
170
chart = new_admissions_chart (alt , projection_admits , 60 - 10 )
170
- assert type (chart ) == alt .Chart
171
+ assert isinstance (chart , alt .Chart )
171
172
assert chart .data .iloc [1 ].Hospitalized < 1
172
173
# assert round(chart.data.iloc[49].ICU, 0) == 43
173
174
with pytest .raises (TypeError ):
@@ -178,8 +179,6 @@ def test_new_admissions_chart():
178
179
179
180
180
181
def test_parameters ():
181
- from penn_chime .models import Parameters
182
- from penn_chime .defaults import RateLos
183
182
param = Parameters (
184
183
current_hospitalized = 100 ,
185
184
doubling_time = 6.0 ,
@@ -223,4 +222,3 @@ def test_parameters():
223
222
# change n_days, make sure it cascades
224
223
param .n_days = 2
225
224
assert len (param .susceptible_v ) == len (param .infected_v ) == len (param .recovered_v ) == param .n_days + 1 == 3
226
-
0 commit comments