Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -16,42 +16,39 @@ def outbreak(plot_type, r, month, countries, social_distancing):
|
|
16 |
pop_count = {"USA": 350, "Canada": 40, "Mexico": 300, "UK": 120}
|
17 |
if social_distancing:
|
18 |
r = sqrt(r)
|
19 |
-
df = pd.DataFrame({"day": x})
|
20 |
-
for country in countries:
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
plt.legend(countries)
|
30 |
return fig
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
inputs = [
|
36 |
-
gr.Dropdown(["Matplotlib", "Plotly", "Altair"], label="Plot Type"),
|
37 |
-
gr.Slider(1, 4, 3.2, label="R"),
|
38 |
-
gr.Dropdown(["January", "February", "March", "April", "May"], label="Month"),
|
39 |
-
gr.CheckboxGroup(
|
40 |
-
["USA", "Canada", "Mexico", "UK"], label="Countries", value=["USA", "Canada"]
|
41 |
-
),
|
42 |
-
gr.Checkbox(label="Social Distancing?"),
|
43 |
-
]
|
44 |
outputs = gr.Plot()
|
45 |
|
46 |
demo = gr.Interface(
|
47 |
-
fn=outbreak,
|
48 |
-
inputs=inputs,
|
49 |
-
outputs=outputs,
|
50 |
-
examples=[
|
51 |
-
["Matplotlib", 2, "March", ["Mexico", "UK"], True]
|
52 |
-
],
|
53 |
-
cache_examples=True,
|
54 |
-
)
|
55 |
|
56 |
if __name__ == "__main__":
|
57 |
demo.launch(share=False)
|
|
|
16 |
pop_count = {"USA": 350, "Canada": 40, "Mexico": 300, "UK": 120}
|
17 |
if social_distancing:
|
18 |
r = sqrt(r)
|
19 |
+
df = pd.DataFrame({"day": x})
|
20 |
+
for country in countries:
|
21 |
+
df[country] = x ** (r) * (pop_count[country] + 1)
|
22 |
+
if plot_type == "Matplotlib":
|
23 |
+
fig = plt.figure()
|
24 |
+
plt.plot(df["day"], df[countries].to_numpy())
|
25 |
+
plt.title("Outbreak in " + month)
|
26 |
+
plt.ylabel("Cases")
|
27 |
+
plt.xlabel("Days since Day 0")
|
28 |
+
plt.legend(countries)
|
|
|
29 |
return fig
|
30 |
+
else:
|
31 |
+
raise ValueError("A plot type must be selected")
|
|
|
|
|
32 |
inputs = [
|
33 |
+
gr.Dropdown(["Matplotlib", "Plotly", "Altair"], label="Plot Type"),
|
34 |
+
gr.Slider(1, 4, 3.2, label="R"),
|
35 |
+
gr.Dropdown(["January", "February", "March", "April", "May"], label="Month"),
|
36 |
+
gr.CheckboxGroup(
|
37 |
+
["USA", "Canada", "Mexico", "UK"], label="Countries", value=["USA", "Canada"]
|
38 |
+
),
|
39 |
+
gr.Checkbox(label="Social Distancing?"),
|
40 |
+
]
|
41 |
outputs = gr.Plot()
|
42 |
|
43 |
demo = gr.Interface(
|
44 |
+
fn=outbreak,
|
45 |
+
inputs=inputs,
|
46 |
+
outputs=outputs,
|
47 |
+
examples=[
|
48 |
+
["Matplotlib", 2, "March", ["Mexico", "UK"], True]
|
49 |
+
],
|
50 |
+
cache_examples=True,
|
51 |
+
)
|
52 |
|
53 |
if __name__ == "__main__":
|
54 |
demo.launch(share=False)
|