Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
12aa17d
Fix JHU's fips-population source file
dshemetov Oct 8, 2020
c8605ad
Revert notebook to template
dshemetov Oct 13, 2020
7ebc144
Merge pull request #301 from cmu-delphi/jhu_nyc_population_fix
krivard Oct 13, 2020
ddb331d
Refactor to use GeoMapper for fips to state
chinandrew Oct 15, 2020
0e1bd78
Change join behavior to match original
chinandrew Oct 15, 2020
ca7ccd0
Remove newline
chinandrew Oct 15, 2020
53f2e6a
Merge branch 'fix_usa_tests' of github.com:sgsmob/covidcast-indicator…
sgsmob Oct 15, 2020
e93d5b6
migrate usafacts geo methods onto GeoMapper. Also fixes pylint compl…
sgsmob Oct 15, 2020
cada509
Update usafacts/delphi_usafacts/geo.py
sgsmob Oct 16, 2020
b55baf9
Merge branch 'weekday' of github.com:sgsmob/covidcast-indicators into…
sgsmob Oct 16, 2020
8ce66a2
convert geo.py to have all double quotes
sgsmob Oct 16, 2020
8fffe96
Fix JHU prop signal by zeroing out the state FIPS population in the p…
dshemetov Oct 18, 2020
296d75d
Improve indicator validation notebook template
dshemetov Oct 19, 2020
84049be
Remove cruise ships FIPS codes, 88888 and 99999
dshemetov Oct 20, 2020
d6cf8c6
Merge branch 'main' of github.com:cmu-delphi/covidcast-indicators int…
sgsmob Oct 20, 2020
fe9a64f
load crosswalk data instead of fips population csv
sgsmob Oct 20, 2020
fd7254e
migrate off of custom fips population file
sgsmob Oct 20, 2020
3145ba1
remove references to old csv file
sgsmob Oct 20, 2020
01439d8
Merge branch 'main' of github.com:cmu-delphi/covidcast-indicators int…
sgsmob Oct 20, 2020
a30dd99
Merge branch 'main' into geo_refactor_safegraph
chinandrew Oct 20, 2020
29c01e6
Undo previous geo_data_proc changes
dshemetov Oct 21, 2020
34a3585
Update add_population_column
dshemetov Oct 21, 2020
a9c5e63
JHU prop signal fix and refactor
dshemetov Oct 21, 2020
ae02415
Update jhu docstring
krivard Oct 22, 2020
af0b3fb
Merge pull request #328 from cmu-delphi/jhu_prop_fix
krivard Oct 22, 2020
af7b20c
add pylintrc file to each indicator
sgsmob Oct 23, 2020
a33414c
Fix geomapper
dshemetov Oct 24, 2020
c1fff63
Remove an extra data.copy in geomapper
dshemetov Oct 24, 2020
3aaba75
Merge branch 'main' of github.com:cmu-delphi/covidcast-indicators int…
sgsmob Oct 28, 2020
330abad
Merge branch 'main' of github.com:cmu-delphi/covidcast-indicators int…
sgsmob Oct 28, 2020
4570423
turn on usafacts::test_run
sgsmob Oct 28, 2020
e18c6f6
Merge branch 'main' of github.com:cmu-delphi/covidcast-indicators int…
sgsmob Oct 28, 2020
455f1dc
lint compliance
sgsmob Oct 28, 2020
008f530
Merge branch 'main' of github.com:cmu-delphi/covidcast-indicators int…
sgsmob Oct 28, 2020
7aa680a
Merge pull request #400 from cmu-delphi/fix_geomapper_popcol
krivard Oct 28, 2020
fcfd2ea
pylint shouldn't complain about capital names for matrix operations
sgsmob Oct 29, 2020
c931139
lint compliance for jhu
sgsmob Oct 29, 2020
68692a9
ignore test outputs
sgsmob Oct 29, 2020
7a8e9db
pylint compliance for quidel_covidtest
sgsmob Oct 29, 2020
aba2c85
lint compliance for usafacts
sgsmob Oct 29, 2020
132bcf8
pylint shouldn't complain about non-member function that actually exists
sgsmob Oct 29, 2020
f04d28f
Merge branch 'pylint_google_health' into pylint
sgsmob Oct 29, 2020
51b33de
Merge branch 'pylint_jhu' into pylint
sgsmob Oct 29, 2020
732ae48
Merge branch 'pylint_quidel_covidtest' into pylint
sgsmob Oct 29, 2020
ab0ab6e
Merge branch 'pylint_usafacts' into pylint
sgsmob Oct 29, 2020
7d84fe6
Merge branch 'main' into deploy-jhu
krivard Oct 29, 2020
2884745
Merge pull request #398 from cmu-delphi/deploy-jhu
krivard Oct 29, 2020
7d50e4e
Merge pull request #335 from cmu-delphi/jhu_cruise_ships_fix
krivard Oct 29, 2020
beb5d87
JHU: Appease the linter
krivard Oct 29, 2020
ab3ebf2
Merge pull request #404 from cmu-delphi/fix/deploy-jhu-linter
krivard Oct 29, 2020
28f13cd
Merge pull request #406 from cmu-delphi/deploy-jhu
krivard Oct 29, 2020
bdaa4c0
Merge pull request #407 from cmu-delphi/deploy-safegraph
krivard Oct 29, 2020
a233937
Merge pull request #399 from sgsmob/usa_tests
krivard Oct 29, 2020
6b407bf
Merge branch 'main' of github.com:cmu-delphi/covidcast-indicators int…
sgsmob Oct 30, 2020
8c73df3
Merge pull request #365 from sgsmob/pylint
krivard Oct 30, 2020
6521db3
Merge branch 'main' into geo
krivard Oct 30, 2020
ca046a6
Merge pull request #313 from cmu-delphi/geo_refactor_safegraph
krivard Oct 30, 2020
8a0a2c0
Merge pull request #316 from sgsmob/geo
krivard Oct 30, 2020
dac4baf
don't alter data frames in place in safegraph
sgsmob Nov 2, 2020
1142a77
remove extraneous functions and calls from usafacts
sgsmob Nov 2, 2020
7fe7294
Merge pull request #420 from sgsmob/safegraph
krivard Nov 2, 2020
dd5e3f2
Merge pull request #421 from sgsmob/usafacts
krivard Nov 2, 2020
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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,7 @@ venv.bak/
.retry
.indicators-ansible-vault-pass
indicators-ansible-vault-pass

# testing_utils
testing_utils/cache
testing_utils/*.csv
21 changes: 17 additions & 4 deletions _delphi_utils_python/.pylintrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
[DESIGN]

min-public-methods=1
[MESSAGES CONTROL]

disable=logging-format-interpolation,
too-many-locals,
too-many-arguments,
# Allow pytest functions to be part of a class.
no-self-use,
# Allow pytest classes to have one test.
too-few-public-methods

[MESSAGES CONTROL]
[BASIC]

# Allow arbitrarily short-named variables.
variable-rgx=[a-z_][a-z0-9_]*
argument-rgx=[a-z_][a-z0-9_]*

[DESIGN]

disable=R0801, C0330, E1101, E0611, C0114, C0116, C0103, R0913, R0914, W0702
# Don't complain about pytest "unused" arguments.
ignored-argument-names=(_.*|run_as_module)
9 changes: 8 additions & 1 deletion _delphi_utils_python/data_proc/geomap/geo_data_proc.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,12 @@ def create_jhu_uid_fips_crosswalk():
{"jhu_uid": "63072999", "fips": "72000", "weight": 1.0},
]
)
cruise_ships = pd.DataFrame(
[
{"jhu_uid": "84088888", "fips": "88888", "weight": 1.0},
{"jhu_uid": "84099999", "fips": "99999", "weight": 1.0},
]
)

jhu_df = (
pd.read_csv(JHU_FIPS_URL, dtype={"UID": str, "FIPS": str})
Expand All @@ -234,7 +240,7 @@ def create_jhu_uid_fips_crosswalk():
# Drop the JHU UIDs that were hand-modified
dup_ind = jhu_df["jhu_uid"].isin(
pd.concat(
[hand_additions, unassigned_states, out_of_state, puerto_rico_unassigned]
[hand_additions, unassigned_states, out_of_state, puerto_rico_unassigned, cruise_ships]
)["jhu_uid"].values
)
jhu_df.drop(jhu_df.index[dup_ind], inplace=True)
Expand Down Expand Up @@ -391,6 +397,7 @@ def create_fips_population_table():
df_pr = df_pr.groupby("fips").sum().reset_index()
df_pr = df_pr[~df_pr["fips"].isin(census_pop["fips"])]
census_pop_pr = pd.concat([census_pop, df_pr])

census_pop_pr.to_csv(join(OUTPUT_DIR, FIPS_POPULATION_OUT_FILENAME), index=False)


Expand Down
2 changes: 0 additions & 2 deletions _delphi_utils_python/delphi_utils/data/jhu_uid_fips_table.csv
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ jhu_uid,fips,weight
63072149,72149,1.0
63072151,72151,1.0
63072153,72153,1.0
84088888,88888,1.0
84099999,99999,1.0
84000001,01000,1.0
84000002,02000,1.0
84000004,04000,1.0
Expand Down
17 changes: 10 additions & 7 deletions _delphi_utils_python/delphi_utils/geomap.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,9 +413,10 @@ def replace_geocode(
df = df.groupby([new_col]).sum().reset_index()
return df

def add_population_column(self, data, geocode_type, geocode_col=None):
def add_population_column(self, data, geocode_type, geocode_col=None, dropna=True):
"""
Appends a population column to a dateframe, based on the FIPS or ZIP code.
Appends a population column to a dataframe, based on the FIPS or ZIP code. If no
dataframe is provided, the full crosswalk from geocode to population is returned.

Parameters
---------
Expand All @@ -433,24 +434,26 @@ def add_population_column(self, data, geocode_type, geocode_col=None):
A dataframe with a population column appended.
"""
geocode_col = geocode_type if geocode_col is None else geocode_col
data = data.copy()

if geocode_type not in ["fips", "zip"]:
raise ValueError(
"Only fips and zip geocodes supported. \
For other codes, aggregate those."
)

pop_df = self._load_crosswalk(from_code=geocode_type, to_code="pop")

if not is_string_dtype(data[geocode_col]):
data[geocode_col] = data[geocode_col].astype(str).str.zfill(5)

pop_df = self._load_crosswalk(from_code=geocode_type, to_code="pop")

merge_type = "inner" if dropna else "left"
data_with_pop = (
data.copy()
.merge(pop_df, left_on=geocode_col, right_on=geocode_type, how="inner")
data
.merge(pop_df, left_on=geocode_col, right_on=geocode_type, how=merge_type)
.rename(columns={"pop": "population"})
)
data_with_pop["population"] = data_with_pop["population"].astype(int)

return data_with_pop

@staticmethod
Expand Down
21 changes: 21 additions & 0 deletions _template_python/.pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

[MESSAGES CONTROL]

disable=logging-format-interpolation,
too-many-locals,
too-many-arguments,
# Allow pytest functions to be part of a class.
no-self-use,
# Allow pytest classes to have one test.
too-few-public-methods

[BASIC]

# Allow arbitrarily short-named variables.
variable-rgx=[a-z_][a-z0-9_]*
argument-rgx=[a-z_][a-z0-9_]*

[DESIGN]

# Don't complain about pytest "unused" arguments.
ignored-argument-names=(_.*|run_as_module)
21 changes: 21 additions & 0 deletions cdc_covidnet/.pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

[MESSAGES CONTROL]

disable=logging-format-interpolation,
too-many-locals,
too-many-arguments,
# Allow pytest functions to be part of a class.
no-self-use,
# Allow pytest classes to have one test.
too-few-public-methods

[BASIC]

# Allow arbitrarily short-named variables.
variable-rgx=[a-z_][a-z0-9_]*
argument-rgx=[a-z_][a-z0-9_]*

[DESIGN]

# Don't complain about pytest "unused" arguments.
ignored-argument-names=(_.*|run_as_module)
21 changes: 21 additions & 0 deletions changehc/.pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

[MESSAGES CONTROL]

disable=logging-format-interpolation,
too-many-locals,
too-many-arguments,
# Allow pytest functions to be part of a class.
no-self-use,
# Allow pytest classes to have one test.
too-few-public-methods

[BASIC]

# Allow arbitrarily short-named variables.
variable-rgx=[a-z_][a-z0-9_]*
argument-rgx=[a-z_][a-z0-9_]*

[DESIGN]

# Don't complain about pytest "unused" arguments.
ignored-argument-names=(_.*|run_as_module)
21 changes: 21 additions & 0 deletions claims_hosp/.pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

[MESSAGES CONTROL]

disable=logging-format-interpolation,
too-many-locals,
too-many-arguments,
# Allow pytest functions to be part of a class.
no-self-use,
# Allow pytest classes to have one test.
too-few-public-methods

[BASIC]

# Allow arbitrarily short-named variables.
variable-rgx=[a-z_][a-z0-9_]*
argument-rgx=[a-z_][a-z0-9_]*

[DESIGN]

# Don't complain about pytest "unused" arguments.
ignored-argument-names=(_.*|run_as_module)
21 changes: 21 additions & 0 deletions combo_cases_and_deaths/.pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

[MESSAGES CONTROL]

disable=logging-format-interpolation,
too-many-locals,
too-many-arguments,
# Allow pytest functions to be part of a class.
no-self-use,
# Allow pytest classes to have one test.
too-few-public-methods

[BASIC]

# Allow arbitrarily short-named variables.
variable-rgx=[a-z_][a-z0-9_]*
argument-rgx=[a-z_][a-z0-9_]*

[DESIGN]

# Don't complain about pytest "unused" arguments.
ignored-argument-names=(_.*|run_as_module)
21 changes: 21 additions & 0 deletions emr_hosp/.pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

[MESSAGES CONTROL]

disable=logging-format-interpolation,
too-many-locals,
too-many-arguments,
# Allow pytest functions to be part of a class.
no-self-use,
# Allow pytest classes to have one test.
too-few-public-methods

[BASIC]

# Allow arbitrarily short-named variables.
variable-rgx=[a-z_][a-z0-9_]*
argument-rgx=[a-z_][a-z0-9_]*

[DESIGN]

# Don't complain about pytest "unused" arguments.
ignored-argument-names=(_.*|run_as_module)
21 changes: 17 additions & 4 deletions google_health/.pylintrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
[DESIGN]

min-public-methods=1
[MESSAGES CONTROL]

disable=logging-format-interpolation,
too-many-locals,
too-many-arguments,
# Allow pytest functions to be part of a class.
no-self-use,
# Allow pytest classes to have one test.
too-few-public-methods

[MESSAGES CONTROL]
[BASIC]

# Allow arbitrarily short-named variables.
variable-rgx=[a-z_][a-z0-9_]*
argument-rgx=[a-z_][a-z0-9_]*

[DESIGN]

disable=R0801, C0330, E1101, E0611, C0114, C0116, C0103, R0913, R0914, W0702
# Don't complain about pytest "unused" arguments.
ignored-argument-names=(_.*|run_as_module)
2 changes: 1 addition & 1 deletion google_health/delphi_google_health/pull_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def query(self, start_date: str, end_date: str, geo_id, dma=False) -> dict:
start_date,
end_date,
)
data = self.service.getTimelinesForHealth(**params).execute()
data = self.service.getTimelinesForHealth(**params).execute() #pylint: disable=no-member

return data

Expand Down
7 changes: 4 additions & 3 deletions google_health/delphi_google_health/smooth.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,12 @@ def _left_gauss_linear(s: np.ndarray, h=10, impute=False, minval=None) -> np.nda

n = len(s)
t = np.zeros_like(s, dtype=np.float64)
X = np.vstack([np.ones(n), np.arange(n)]).T
X = np.vstack([np.ones(n), np.arange(n)]).T #pylint: disable=invalid-name
for idx in range(n):
wts = np.exp(-((np.arange(idx + 1) - idx) ** 2) / (h ** 2))
XwX = np.dot(X[: (idx + 1), :].T * wts, X[: (idx + 1), :])
Xwy = np.dot(X[: (idx + 1), :].T * wts, s[: (idx + 1)].reshape(-1, 1))
XwX = np.dot(X[: (idx + 1), :].T * wts, X[: (idx + 1), :]) #pylint: disable=invalid-name
Xwy = np.dot(X[: (idx + 1), :].T * wts, #pylint: disable=invalid-name
s[: (idx + 1)].reshape(-1, 1))
try:
beta = np.linalg.solve(XwX, Xwy)
t[idx] = np.dot(X[: (idx + 1), :], beta)[-1]
Expand Down
21 changes: 17 additions & 4 deletions jhu/.pylintrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
[DESIGN]

min-public-methods=1
[MESSAGES CONTROL]

disable=logging-format-interpolation,
too-many-locals,
too-many-arguments,
# Allow pytest functions to be part of a class.
no-self-use,
# Allow pytest classes to have one test.
too-few-public-methods

[MESSAGES CONTROL]
[BASIC]

# Allow arbitrarily short-named variables.
variable-rgx=[a-z_][a-z0-9_]*
argument-rgx=[a-z_][a-z0-9_]*

[DESIGN]

disable=R0801, C0330, E1101, E0611, C0114, C0116, C0103, R0913, R0914, W0702
# Don't complain about pytest "unused" arguments.
ignored-argument-names=(_.*|run_as_module)
9 changes: 8 additions & 1 deletion jhu/delphi_jhu/geo.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# -*- coding: utf-8 -*-
"""Functions for translating between geocodes."""
import pandas as pd
from delphi_utils import GeoMapper

VALID_GEO_RES = ("county", "state", "msa", "hrr")
INCIDENCE_BASE = 100000

def geo_map(df: pd.DataFrame, geo_res: str):
Expand All @@ -27,14 +29,19 @@ def geo_map(df: pd.DataFrame, geo_res: str):
Columns: geo_id, timestamp, ...
"""
df = df.copy()
VALID_GEO_RES = ("county", "state", "msa", "hrr")
if geo_res not in VALID_GEO_RES:
raise ValueError(f"geo_res must be one of {VALID_GEO_RES}")

gmpr = GeoMapper()
if geo_res == "county":
df.rename(columns={'fips': 'geo_id'}, inplace=True)
elif geo_res == "state":
df = df.set_index("fips")
# Zero out the state FIPS population to avoid double counting.
state_fips_codes = {str(x).zfill(2) + "000" for x in range(1,73)}
subset_state_fips_codes = set(df.index.values) & state_fips_codes
df.loc[subset_state_fips_codes, "population"] = 0
df = df.reset_index()
df = gmpr.replace_geocode(df, "fips", "state_id", new_col="geo_id", date_col="timestamp")
else:
df = gmpr.replace_geocode(df, "fips", geo_res, new_col="geo_id", date_col="timestamp")
Expand Down
Loading