Skip to content

Commit 2cca35d

Browse files
Merge branch 'develop' into issue_119
2 parents fb9c640 + b366ee0 commit 2cca35d

File tree

7 files changed

+100
-18
lines changed

7 files changed

+100
-18
lines changed

__init__.py

Whitespace-only changes.

docs/CONTRIBUTING.md

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,46 @@
11
# Contributing
22

3-
When contributing to this repository, please first discuss the change you wish to make via [issue](https://github.com/codeforphilly/chime/issues), [Slack chat](https://codeforphilly.org/chat/covid19-chime-penn), or any other method with the owners of this repository before making a change.
3+
Welcome, grab a cup of coffee, and let's roll our sleeves up! By participating in this project, you agree to abide by our [code of conduct](CODE_OF_CONDUCT.md).
44

5-
Please note we have a [code of conduct](CODE_OF_CONDUCT.md), please follow it in all your interactions with the project.
5+
## What should I work on?
66

7-
## Active Needs
7+
As of March 19, help is especially wanted in these areas:
88

9-
We maintain a list of [issues in the Code for Philly repo](https://github.com/codeforphilly/chime/issues) that encompasses work requested by stakeholders and technologists. Each issue is designed to be small enough for one person to implement.
9+
- **Python wizards** for application development ([#chime-app](https://codeforphilly.org/chat?channel=chime-app))
10+
- Hardening the code
11+
- Making it more flexible
12+
- Unit tests!
13+
- **DevOps heroes** for application hosting ([#chime-ops](https://codeforphilly.org/chat?channel=chime-ops))
14+
- Maintaining Penn's instance
15+
- Ensuring easy redeploys
16+
- **Math and stats friends** for model improvements ([#chime-analysis](https://codeforphilly.org/chat?channel=chime-analysis))
17+
- **Consulting DevOps champs** to help other public agencies set up their own instances ([#chime-help](https://codeforphilly.org/chat?channel=chime-help)
1018

11-
**Developers** If you are new to the project, check out open issues to see if there is any pre-existing work needed that you can handle. We will need to add your git account to the repo to grant write access - contact us on [Slack](https://codeforphilly.org/chat) in the [covid19-chime-penn](https://codeforphilly.org/chat?channel=covid19-chime-penn) channel.
19+
## Before You Begin
1220

13-
## Change Management
21+
- Join the [#covid19-chime-penn](https://codeforphilly.org/chat?channel=covid19-chime-penn) channel, and [request write access](https://codeforphilly.slack.com/archives/CV4NGQYMP/p1584665484368300) to the `CodeforPhilly/chime` Github repository.
22+
- Our highest-priority work is organized in the [Github Project Management board](https://github.com/CodeForPhilly/chime/projects/2). Look for an issue matching your interests & skills in one of the "Ready" columns.
23+
- Assign yourself to the issue and add a comment to briefly describe your plan.
24+
- For new ideas, please first discuss the change(s) you wish to make via [issue](https://github.com/codeforphilly/chime/issues) or appropriate Slack channel (platform/app - #chime-app, devops - #chime-ops, modeling - #chime-analysis).
1425

15-
- Base all work on the latest `develop` branch available in [Code for Philly's fork of the `chime` repository](https://github.com/CodeForPhilly/chime).
16-
- Submit your work in the form of a pull request against that same branch.
17-
- Check in on your pull request periodically after you submit it to see if any changes have been requested or any merge conflicts have arisen from other work getting integrated.
18-
- If a merge conflict arises, please rebase your branch against the latest `develop` branch and force-push the new branch as early as you can. You may need to do this more than once before your changes get merged. Do your best to keep your branch in a mergeable state until it is finished being reviewed and accepted.
26+
## Making and Submitting Changes
27+
28+
- [Fork](https://help.github.com/en/github/getting-started-with-github/fork-a-repo) the [CodeforPhilly/chime](https://github.com/CodeForPhilly/chime) repo.
29+
- Base your work on the `develop` branch.
30+
- Submit pull requests from your fork, also against the `develop` branch of the `CodeforPhilly/chime` repo.
31+
- Check your pull request periodically to see if any changes have been requested or any merge conflicts have arisen.
32+
- If a merge conflict arises, rebase against the latest `develop` branch and force-push the new branch as early as you can. You may need to do this more than once before your changes get merged. Do your best to keep your branch in a mergeable state until it is finished being reviewed and accepted.
33+
- Note: Frequent contributors with write access can submit pull requests from a new branch in the `CodeforPhilly/chime` repository.
34+
35+
## Review & Release
36+
37+
<!-- Currently establishing & clarifying the release process, this is just a skeleton. -->
38+
39+
- Maintainers will review pull requests, asking for changes as needed.
40+
- Once a PR has 1 approval and passes automated tests, maintainers will merge to release branches.
41+
- Exception: Documentation or infrastructure support PRs can be merged directly to master.
42+
- Deploys to production must be signed off on by @beckerfluffle or @cchivers.
1943

2044
## Requesting Functionality
2145

22-
**Stakeholders/Users** Find us on [Slack](https://codeforphilly.org/chat) in the [#covid19-chime-penn](https://codeforphilly.org/chat/covid19-chime-penn) channel to see if your need is already being addressed.
46+
**Stakeholders/Users**: Check the [#covid19-chime-penn](https://codeforphilly.org/chat/covid19-chime-penn) channel on [Slack](https://codeforphilly.org/chat) to see if your need is already being addressed.

docs/operations/chime-live-cluster.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
## Deploying a New CHIME Version
3434

35-
1. [MaCreateke a new release](release-process.md)
35+
1. [Create a new release](release-process.md)
3636
2. Wait for the `Docker` GitHub Actions workflow to complete
3737
3. Verify the new version shows up at the top as "Latest version" here: https://github.com/CodeForPhilly/chime/packages/155340
3838
4. Run:

penn_chime/models.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
from typing import Tuple
22

33
import numpy as np
4+
import streamlit as st
45

56

67
# The SIR model, one time step
8+
@st.cache
79
def sir(y, beta, gamma, N):
810
S, I, R = y
911
Sn = (-beta * S * I) + S
@@ -21,6 +23,7 @@ def sir(y, beta, gamma, N):
2123

2224

2325
# Run the SIR model forward in time
26+
@st.cache
2427
def sim_sir(
2528
S, I, R, beta, gamma, n_days, beta_decay=0
2629
) -> Tuple[np.ndarray, np.ndarray, np.ndarray]:
@@ -37,7 +40,7 @@ def sim_sir(
3740
s, i, r = np.array(s), np.array(i), np.array(r)
3841
return s, i, r
3942

40-
43+
@st.cache
4144
def get_hospitalizations(
4245
infected: np.ndarray, rates: Tuple[float, float, float], market_share: float
4346
) -> Tuple[np.ndarray, np.ndarray, np.ndarray]:

penn_chime/presentation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def display_header(
4646
st.markdown(
4747
"""*This tool was developed by the [Predictive Healthcare team](http://predictivehealthcare.pennmedicine.org/) at
4848
Penn Medicine. For questions and comments please see our
49-
[contact page](http://predictivehealthcare.pennmedicine.org/contact/). Code can be found on [Github](https://github.com/pennsignals/chime).
49+
[contact page](http://predictivehealthcare.pennmedicine.org/contact/). Code can be found on [Github](https://github.com/CodeForPhilly/chime).
5050
Join our [Slack channel](https://codeforphilly.org/chat?channel=covid19-chime-penn) if you would like to get involved!*"""
5151
)
5252

penn_chime/utils.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import numpy as np
22
import pandas as pd
3+
import streamlit as st
34

4-
5+
@st.cache
56
def build_admissions_df(n_days, hosp, icu, vent) -> pd.DataFrame:
67
days = np.array(range(0, n_days + 1))
78
data_dict = dict(zip(["day", "hosp", "icu", "vent"], [days, hosp, icu, vent]))
@@ -12,7 +13,7 @@ def build_admissions_df(n_days, hosp, icu, vent) -> pd.DataFrame:
1213
projection_admits["day"] = range(projection_admits.shape[0])
1314
return projection_admits
1415

15-
16+
@st.cache
1617
def build_census_df(projection_admits, hosp_los, icu_los, vent_los) -> pd.DataFrame:
1718
"""ALOS for each category of COVID-19 case (total guesses)"""
1819
n_days = np.shape(projection_admits)[0]

test_app.py

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
import pytest
2+
import pandas as pd
23

3-
from penn_chime.models import sir
4-
from penn_chime.presentation import display_header
4+
from app import (S_default, known_infections, known_cases, current_hosp, doubling_time, relative_contact_rate,
5+
hosp_rate, icu_rate, vent_rate, hosp_los, icu_los, vent_los, market_share, S, initial_infections,
6+
detection_prob, hospitalization_rates, I, R, beta, gamma, n_days, beta_decay,
7+
projection_admits, alt)
8+
from penn_chime.models import sir, sim_sir
9+
from penn_chime.presentation import display_header, new_admissions_chart
510

611

712
# set up
@@ -75,3 +80,52 @@ def test_sir():
7580
0.20297029702970298,
7681
0.0049504950495049506,
7782
), "This contrived example should work"
83+
84+
85+
def test_sim_sir():
86+
"""
87+
Rounding to move fast past decimal place issues
88+
"""
89+
s, i, r = sim_sir(S, I, R, beta, gamma, n_days, beta_decay=beta_decay)
90+
assert round(s[0], 0) == 4119405
91+
assert round(s[-1], 2) == 3421436.31
92+
assert round(i[0], 2) == 533.33
93+
assert round(i[-1], 2) == 418157.62
94+
assert round(r[0], 0) == 0
95+
assert round(r[-1], 2) == 280344.40
96+
97+
98+
def test_initial_conditions():
99+
"""
100+
Note: For the rates (ie hosp_rate) - just change the value, leave the "100" alone.
101+
Easier to change whole numbers than decimals.
102+
"""
103+
assert current_hosp == known_cases
104+
assert doubling_time == 6
105+
assert relative_contact_rate == 0
106+
assert hosp_rate == 5 / 100
107+
assert icu_rate == 2 / 100
108+
assert vent_rate == 1 / 100
109+
assert hosp_los == 7
110+
assert icu_los == 9
111+
assert vent_los == 10
112+
assert market_share == 15 / 100
113+
assert S == S_default
114+
assert initial_infections == known_infections
115+
116+
117+
def test_derived_variables():
118+
assert hospitalization_rates == (hosp_rate, icu_rate, vent_rate)
119+
assert detection_prob == initial_infections / (current_hosp / market_share / hosp_rate)
120+
121+
122+
def test_new_admissions_chart():
123+
chart = new_admissions_chart(alt, projection_admits, n_days - 10)
124+
assert type(chart) == alt.Chart
125+
assert chart.data.iloc[1].Hospitalized < 1
126+
assert round(chart.data.iloc[49].ICU, 0) == 43
127+
with pytest.raises(TypeError):
128+
new_admissions_chart()
129+
130+
empty_chart = new_admissions_chart(alt, pd.DataFrame(), -1)
131+
assert empty_chart.data.empty

0 commit comments

Comments
 (0)