Skip to content

Commit 9971712

Browse files
authored
Merge pull request #1486 from cmu-delphi/release/indicators_v0.2.23_utils_v0.2.11
Release covidcast-indicators 0.2.23
2 parents 6abcab3 + dee7c94 commit 9971712

File tree

24 files changed

+258
-156
lines changed

24 files changed

+258
-156
lines changed

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 0.2.22
2+
current_version = 0.2.23
33
commit = True
44
message = chore: bump covidcast-indicators to {new_version}
55
tag = False

_delphi_utils_python/.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 0.2.10
2+
current_version = 0.2.11
33
commit = True
44
message = chore: bump delphi_utils to {new_version}
55
tag = False

_delphi_utils_python/delphi_utils/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@
1515
from .nancodes import Nans
1616
from .weekday import Weekday
1717

18-
__version__ = "0.2.10"
18+
__version__ = "0.2.11"

_delphi_utils_python/setup.py

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

2727
setup(
2828
name="delphi_utils",
29-
version="0.2.10",
29+
version="0.2.11",
3030
description="Shared Utility Functions for Indicators",
3131
long_description=long_description,
3232
long_description_content_type="text/markdown",

_delphi_utils_python/tests/test_geomap.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,14 @@ class TestGeoMapper:
104104
),
105105
)
106106
)
107+
mega_data_3 = pd.DataFrame(
108+
{
109+
"fips": [1123, 1125, 1126, 1128, 1129, 18181],
110+
"timestamp": [pd.Timestamp("2018-01-01")] * 6,
111+
"visits": [4, 1, 2, 5, 10, 100001],
112+
"count": [2, 1, 5, 7, 3, 10021],
113+
}
114+
)
107115
jhu_uid_data = pd.DataFrame(
108116
{
109117
"jhu_uid": [
@@ -208,6 +216,27 @@ def test_megacounty(self, geomapper):
208216
new_data[["count"]].sum() - self.mega_data[["count"]].sum()
209217
).sum() < 1e-3
210218

219+
new_data = geomapper.fips_to_megacounty(self.mega_data_3, 4, 1)
220+
expected_df = pd.DataFrame(
221+
{
222+
"megafips": ["01000", "01128", "01129", "18181"],
223+
"timestamp": [pd.Timestamp("2018-01-01")] * 4,
224+
"visits": [7, 5, 10, 100001],
225+
"count": [8, 7, 3, 10021],
226+
}
227+
)
228+
pd.testing.assert_frame_equal(new_data.set_index("megafips").sort_index(axis=1), expected_df.set_index("megafips").sort_index(axis=1))
229+
new_data = geomapper.fips_to_megacounty(self.mega_data_3, 4, 1, thr_col="count")
230+
expected_df = pd.DataFrame(
231+
{
232+
"megafips": ["01000", "01126", "01128", "18181"],
233+
"timestamp": [pd.Timestamp("2018-01-01")] * 4,
234+
"visits": [15, 2, 5, 100001],
235+
"count": [6, 5, 7, 10021],
236+
}
237+
)
238+
pd.testing.assert_frame_equal(new_data.set_index("megafips").sort_index(axis=1), expected_df.set_index("megafips").sort_index(axis=1))
239+
211240
def test_add_population_column(self, geomapper):
212241
new_data = geomapper.add_population_column(self.fips_data_3, "fips")
213242
assert new_data.shape == (5, 5)

ansible/templates/dsew_community_profile-params-prod.json.j2

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
},
66
"indicator": {
77
"input_cache": "./input_cache",
8-
"reports": "new"
8+
"reports": "new",
9+
"export_signals": ["confirmed covid-19 admissions"]
910
},
1011
"validation": {
1112
"common": {

ansible/templates/google_symptoms-params-prod.json.j2

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,13 @@
3636
"dynamic": {
3737
"ref_window_size": 7,
3838
"smoothed_signals": [
39-
"ageusia_smoothed_search",
40-
"sum_anosmia_ageusia_smoothed_search",
41-
"anosmia_smoothed_search"
39+
"s01_smoothed_search",
40+
"s02_smoothed_search",
41+
"s03_smoothed_search",
42+
"s05_smoothed_search",
43+
"s06_smoothed_search",
44+
"s08_smoothed_search",
45+
"scontrol_smoothed_search"
4246
]
4347
}
4448
},

dsew_community_profile/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ Indicator-specific parameters:
2323
and exported.
2424
* `export_start_date`: a YYYY-mm-dd string indicating the first date to export.
2525
* `export_end_date`: a YYYY-mm-dd string indicating the final date to export.
26+
* `export_signals`: list of string keys from constants.SIGNALS indicating which
27+
signals to export
2628

2729
## Running the Indicator
2830

dsew_community_profile/delphi_dsew_community_profile/pull.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,12 +342,16 @@ def nation_from_state(df, sig, geomapper):
342342
).drop(
343343
"norm_denom", axis=1
344344
)
345-
return geomapper.replace_geocode(
345+
df = geomapper.replace_geocode(
346346
df,
347347
'state_id',
348348
'nation',
349349
new_col="geo_id"
350350
)
351+
df["se"] = None
352+
df["sample_size"] = None
353+
354+
return df
351355

352356
def fetch_new_reports(params, logger=None):
353357
"""Retrieve, compute, and collate all data we haven't seen yet."""
@@ -367,10 +371,21 @@ def fetch_new_reports(params, logger=None):
367371
lambda x: x[x["publish_date"] == x["publish_date"].max()]
368372
).drop(
369373
"publish_date", axis=1
374+
).drop_duplicates(
370375
)
371376

372377
if len(latest_sig_df.index) > 0:
373-
ret[sig] = latest_sig_df.reset_index(drop=True)
378+
latest_sig_df = latest_sig_df.reset_index(drop=True)
379+
380+
assert all(latest_sig_df.groupby(
381+
["timestamp", "geo_id"]
382+
).size(
383+
).reset_index(
384+
drop=True
385+
) == 1), f"Duplicate rows in {sig} indicate that one or" \
386+
+ " more reports was published multiple times and the copies differ"
387+
388+
ret[sig] = latest_sig_df
374389

375390
# add nation from state
376391
geomapper = GeoMapper()

dsew_community_profile/delphi_dsew_community_profile/run.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,12 @@ def run_module(params):
3838
__name__, filename=params["common"].get("log_filename"),
3939
log_exceptions=params["common"].get("log_exceptions", True))
4040
def replace_date_param(p):
41-
if p in params["indicator"] and params["indicator"][p] is not None:
42-
date_param = datetime.strptime(params["indicator"][p], "%Y-%m-%d").date()
43-
params["indicator"][p] = date_param
41+
if p in params["indicator"]:
42+
if params["indicator"][p] is None:
43+
del params["indicator"][p]
44+
else:
45+
date_param = datetime.strptime(params["indicator"][p], "%Y-%m-%d").date()
46+
params["indicator"][p] = date_param
4447
replace_date_param("export_start_date")
4548
replace_date_param("export_end_date")
4649
export_params = {
@@ -56,6 +59,8 @@ def replace_date_param(p):
5659
dfs = fetch_new_reports(params, logger)
5760
for key, df in dfs.items():
5861
(geo, sig) = key
62+
if sig not in params["indicator"]["export_signals"]:
63+
continue
5964
dates = create_export_csv(
6065
df,
6166
params['common']['export_dir'],

0 commit comments

Comments
 (0)