Skip to content

Commit da39136

Browse files
author
PJ Hoberman
committed
minor pylint cleanup
1 parent 371356a commit da39136

File tree

1 file changed

+17
-19
lines changed

1 file changed

+17
-19
lines changed

src/test_app.py

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33

44

55
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
77
from penn_chime.presentation import display_header, new_admissions_chart
88
from penn_chime.settings import DEFAULTS
9+
from penn_chime.defaults import RateLos
910

1011

1112
# set up
@@ -67,7 +68,7 @@ def test_header_fail():
6768
st.cleanup()
6869

6970

70-
def test_defaultS_repr():
71+
def test_defaults_repr():
7172
"""
7273
Test DEFAULTS.repr
7374
"""
@@ -87,29 +88,29 @@ def test_sir():
8788
), "This contrived example should work"
8889

8990
# Certain things should *not* work
90-
with pytest.raises(TypeError) as E:
91+
with pytest.raises(TypeError) as error:
9192
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'"
9394

94-
with pytest.raises(TypeError) as E:
95+
with pytest.raises(TypeError) as error:
9596
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'"
9798

98-
with pytest.raises(TypeError) as E:
99+
with pytest.raises(TypeError) as error:
99100
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'"
101102

102-
with pytest.raises(TypeError) as E:
103+
with pytest.raises(TypeError) as error:
103104
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'"
105106

106-
with pytest.raises(TypeError) as E:
107+
with pytest.raises(TypeError) as error:
107108
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'"
109110

110-
with pytest.raises(TypeError) as E:
111+
with pytest.raises(TypeError) as error:
111112
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'"
113114

114115
# Zeros across the board should fail
115116
with pytest.raises(ZeroDivisionError):
@@ -120,7 +121,7 @@ def test_sim_sir():
120121
"""
121122
Rounding to move fast past decimal place issues
122123
"""
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)
124125

125126
assert round(s[0], 0) == 5
126127
assert round(i[0], 2) == 6
@@ -167,7 +168,7 @@ def test_sim_sir_df():
167168

168169
def test_new_admissions_chart():
169170
chart = new_admissions_chart(alt, projection_admits, 60 - 10)
170-
assert type(chart) == alt.Chart
171+
assert isinstance(chart, alt.Chart)
171172
assert chart.data.iloc[1].Hospitalized < 1
172173
# assert round(chart.data.iloc[49].ICU, 0) == 43
173174
with pytest.raises(TypeError):
@@ -178,8 +179,6 @@ def test_new_admissions_chart():
178179

179180

180181
def test_parameters():
181-
from penn_chime.models import Parameters
182-
from penn_chime.defaults import RateLos
183182
param = Parameters(
184183
current_hospitalized=100,
185184
doubling_time=6.0,
@@ -223,4 +222,3 @@ def test_parameters():
223222
# change n_days, make sure it cascades
224223
param.n_days = 2
225224
assert len(param.susceptible_v) == len(param.infected_v) == len(param.recovered_v) == param.n_days + 1 == 3
226-

0 commit comments

Comments
 (0)