Skip to content

[DSEW CPR] Pass through python-black #1577

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 32 additions & 31 deletions dsew_community_profile/delphi_dsew_community_profile/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

INTERP_LENGTH = 5


@dataclass
class Transform:
"""Transformation filters for interpreting a particular sheet in the workbook."""
Expand All @@ -18,35 +19,32 @@ class Transform:
geo_id_select: function = None
geo_id_apply: function = None


T_FIRST = lambda df: df[df.columns[0]]
TRANSFORMS = {
t.name: t for t in [
t.name: t
for t in [
Transform(
name="Regions",
level="hhs",
geo_id_select=lambda df: df.index.to_series(),
geo_id_apply=lambda x: x.replace("Region ", "")
geo_id_apply=lambda x: x.replace("Region ", ""),
),
Transform(
name="States",
level="state",
geo_id_select=T_FIRST,
geo_id_apply=lambda x: x.lower()
name="States", level="state", geo_id_select=T_FIRST, geo_id_apply=lambda x: x.lower()
),
Transform(
name="CBSAs",
level="msa",
row_filter=lambda df: df['CBSA type'] == "Metropolitan",
row_filter=lambda df: df["CBSA type"] == "Metropolitan",
geo_id_select=T_FIRST,
geo_id_apply=lambda x: f"{x}"
geo_id_apply=lambda x: f"{x}",
),
Transform(
name="Counties",
level="county",
geo_id_select=T_FIRST,
geo_id_apply=lambda x: f"{x:05}"
)
]}
name="Counties", level="county", geo_id_select=T_FIRST, geo_id_apply=lambda x: f"{x:05}"
),
]
}

# key: signal id, string pattern used to find column to report as signal
# is_rate: originating signal is a percentage (e.g. test positivity)
Expand All @@ -56,52 +54,54 @@ class Transform:
# api_prop_name: name to use in API for proportion signal
SIGNALS = {
"total": {
"is_rate" : False,
"is_rate": False,
"api_name": "covid_naat_num_7dav",
"make_prop": False,
"is_cumulative" : False
"is_cumulative": False,
},
"positivity": {
"is_rate" : True,
"is_rate": True,
"api_name": "covid_naat_pct_positive_7dav",
"make_prop": False,
"is_cumulative" : False
"is_cumulative": False,
},
"confirmed covid-19 admissions": {
"is_rate" : False,
"is_rate": False,
"api_name": "confirmed_admissions_covid_1d_7dav",
"make_prop": True,
"api_prop_name": "confirmed_admissions_covid_1d_prop_7dav",
"is_cumulative" : False
"is_cumulative": False,
},
"fully vaccinated": {
"is_rate" : False,
"is_rate": False,
"api_name": "people_full_vaccinated",
"make_prop": False,
"is_cumulative" : True
"is_cumulative": True,
},
"booster dose since": {
"is_rate" : False,
"is_rate": False,
"api_name": "people_booster_doses",
"make_prop": False,
"is_cumulative" : True
"is_cumulative": True,
},
"booster doses administered": {
"is_rate" : False,
"is_rate": False,
"api_name": "booster_doses_admin_7dav",
"make_prop": False,
"is_cumulative" : False
"is_cumulative": False,
},
"doses administered": {
"is_rate" : False,
"is_rate": False,
"api_name": "doses_admin_7dav",
"make_prop": False,
"is_cumulative" : False
}
"is_cumulative": False,
},
}

COUNTS_7D_SIGNALS = {
key for key, value in SIGNALS.items() if not ((value["is_rate"]) or (value["is_cumulative"]))
}

COUNTS_7D_SIGNALS = {key for key, value in SIGNALS.items() \
if not((value["is_rate"]) or (value["is_cumulative"]))}

def make_signal_name(key, is_prop=False):
"""Convert a signal key to the corresponding signal name for the API.
Expand All @@ -113,6 +113,7 @@ def make_signal_name(key, is_prop=False):
return SIGNALS[key]["api_prop_name"]
return SIGNALS[key]["api_name"]


NEWLINE = "\n"
IS_PROP = True
NOT_PROP = False
Loading