Skip to content

Commit 9517792

Browse files
committed
Merge branch 'main' into krivard/chng-empty-files
2 parents 04215f3 + ef13336 commit 9517792

File tree

75 files changed

+14603
-14464
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+14603
-14464
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.1.21
2+
current_version = 0.1.25
33
commit = True
44
message = chore: bump covidcast-indicators to {new_version}
55
tag = False

.github/workflows/r-ci.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,12 @@ jobs:
4848
${{ runner.os }}-r-facebook-survey-
4949
- name: Install R dependencies
5050
run: |
51-
if ( !require("readr") || packageVersion("readr") != "1.4.0" ) {
52-
install.packages("devtools")
53-
devtools::install_version("readr", version = "1.4.0")
54-
}
55-
5651
if ( !require("remotes") ) {
5752
install.packages("remotes")
5853
}
5954
remotes::update_packages(c("rcmdcheck", "mockr", "remotes"), upgrade="always")
6055
dependency_list <- remotes::dev_package_deps(dependencies=TRUE)
61-
remotes::update_packages(dependency_list$package[dependency_list$package != "readr"], upgrade="always")
56+
remotes::update_packages(dependency_list$package, upgrade="always")
6257
shell: Rscript {0}
6358
- name: Check
6459
run: |

_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.1.15
2+
current_version = 0.1.17
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
@@ -14,4 +14,4 @@
1414
from .signal import add_prefix
1515
from .nancodes import Nans
1616

17-
__version__ = "0.1.15"
17+
__version__ = "0.1.17"

_delphi_utils_python/delphi_utils/geomap.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ def megacounty_creation(
183183
thr_win_len,
184184
thr_col="visits",
185185
fips_col="fips",
186-
date_col="date",
186+
date_col="timestamp",
187187
mega_col="megafips",
188188
):
189189
"""Create megacounty column.
@@ -340,7 +340,7 @@ def replace_geocode(
340340
new_code,
341341
from_col=None,
342342
new_col=None,
343-
date_col="date",
343+
date_col="timestamp",
344344
data_cols=None,
345345
dropna=True,
346346
):
@@ -366,7 +366,7 @@ def replace_geocode(
366366
new_code: {'fips', 'zip', 'state_code', 'state_id', 'state_name', 'hrr', 'msa',
367367
'hhs'}
368368
Specifies the geocode type of the data in new_col.
369-
date_col: str or None, default "date"
369+
date_col: str or None, default "timestamp"
370370
Specify which column contains the date values. Used for value aggregation.
371371
If None, then the aggregation is done only on geo_id.
372372
data_cols: list, default None
@@ -457,7 +457,7 @@ def fips_to_megacounty(
457457
thr_win_len,
458458
thr_col="visits",
459459
fips_col="fips",
460-
date_col="date",
460+
date_col="timestamp",
461461
mega_col="megafips",
462462
count_cols=None,
463463
):

_delphi_utils_python/delphi_utils/utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,5 @@ def transfer_files():
9595
delivery_dir = params["delivery"].get("delivery_dir", None)
9696
files_to_export = os.listdir(export_dir)
9797
for file_name in files_to_export:
98-
move(os.path.join(export_dir, file_name), delivery_dir)
98+
if file_name.endswith(".csv") or file_name.endswith(".CSV"):
99+
move(os.path.join(export_dir, file_name), delivery_dir)

_delphi_utils_python/setup.py

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

2626
setup(
2727
name="delphi_utils",
28-
version="0.1.15",
28+
version="0.1.17",
2929
description="Shared Utility Functions for Indicators",
3030
long_description=long_description,
3131
long_description_content_type="text/markdown",

_delphi_utils_python/tests/test_geomap.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,47 +15,47 @@ class TestGeoMapper:
1515
fips_data = pd.DataFrame(
1616
{
1717
"fips": ["01123", "02340", "98633", "18181"],
18-
"date": [pd.Timestamp("2018-01-01")] * 4,
18+
"timestamp": [pd.Timestamp("2018-01-01")] * 4,
1919
"count": [2, 0, 20, 10021],
2020
"total": [4, 0, 400, 100001],
2121
}
2222
)
2323
fips_data_2 = pd.DataFrame(
2424
{
2525
"fips": ["01123", "02340", "02002", "18633", "18181"],
26-
"date": [pd.Timestamp("2018-01-01")] * 5,
26+
"timestamp": [pd.Timestamp("2018-01-01")] * 5,
2727
"count": [2, 1, 20, np.nan, 10021],
2828
"total": [4, 1, 400, np.nan, 100001],
2929
}
3030
)
3131
fips_data_3 = pd.DataFrame(
3232
{
3333
"fips": ["48059", "48253", "48441", "72003", "72005", "10999"],
34-
"date": [pd.Timestamp("2018-01-01")] * 3 + [pd.Timestamp("2018-01-03")] * 3,
34+
"timestamp": [pd.Timestamp("2018-01-01")] * 3 + [pd.Timestamp("2018-01-03")] * 3,
3535
"count": [1, 2, 3, 4, 8, 5],
3636
"total": [2, 4, 7, 11, 100, 10],
3737
}
3838
)
3939
fips_data_4 = pd.DataFrame(
4040
{
4141
"fips": ["01123", "48253", "72003", "18181"],
42-
"date": [pd.Timestamp("2018-01-01")] * 4,
42+
"timestamp": [pd.Timestamp("2018-01-01")] * 4,
4343
"count": [2, 1, np.nan, 10021],
4444
"total": [4, 1, np.nan, 100001],
4545
}
4646
)
4747
fips_data_5 = pd.DataFrame(
4848
{
4949
"fips": [1123, 48253, 72003, 18181],
50-
"date": [pd.Timestamp("2018-01-01")] * 4,
50+
"timestamp": [pd.Timestamp("2018-01-01")] * 4,
5151
"count": [2, 1, np.nan, 10021],
5252
"total": [4, 1, np.nan, 100001],
5353
}
5454
)
5555
zip_data = pd.DataFrame(
5656
{
5757
"zip": ["45140", "95616", "95618"] * 2,
58-
"date": [pd.Timestamp("2018-01-01")] * 3 + [pd.Timestamp("2018-01-03")] * 3,
58+
"timestamp": [pd.Timestamp("2018-01-01")] * 3 + [pd.Timestamp("2018-01-03")] * 3,
5959
"count": [99, 345, 456, 100, 344, 442],
6060
}
6161
)
@@ -66,15 +66,15 @@ class TestGeoMapper:
6666
pd.DataFrame(
6767
{
6868
"fips": ["01001"] * len(jan_month),
69-
"date": jan_month,
69+
"timestamp": jan_month,
7070
"count": np.arange(len(jan_month)),
7171
"visits": np.arange(len(jan_month)),
7272
}
7373
),
7474
pd.DataFrame(
7575
{
7676
"fips": ["01002"] * len(jan_month),
77-
"date": jan_month,
77+
"timestamp": jan_month,
7878
"count": np.arange(len(jan_month)),
7979
"visits": 2 * np.arange(len(jan_month)),
8080
}
@@ -86,15 +86,15 @@ class TestGeoMapper:
8686
pd.DataFrame(
8787
{
8888
"fips": ["01001"] * len(jan_month),
89-
"date": jan_month,
89+
"timestamp": jan_month,
9090
"count": np.arange(len(jan_month)),
9191
"_thr_col_roll": np.arange(len(jan_month)),
9292
}
9393
),
9494
pd.DataFrame(
9595
{
9696
"fips": [11001] * len(jan_month),
97-
"date": jan_month,
97+
"timestamp": jan_month,
9898
"count": np.arange(len(jan_month)),
9999
"_thr_col_roll": np.arange(len(jan_month)),
100100
}
@@ -112,7 +112,7 @@ class TestGeoMapper:
112112
84000013,
113113
84090002,
114114
],
115-
"date": [pd.Timestamp("2018-01-01")] * 3
115+
"timestamp": [pd.Timestamp("2018-01-01")] * 3
116116
+ [pd.Timestamp("2018-01-03")] * 3
117117
+ [pd.Timestamp("2018-01-01")],
118118
"count": [1, 2, 3, 4, 8, 5, 20],
@@ -245,7 +245,7 @@ def test_add_geocode(self, geomapper):
245245
new_data,
246246
pd.DataFrame().from_dict(
247247
{
248-
"date": {0: pd.Timestamp("2018-01-01 00:00:00")},
248+
"timestamp": {0: pd.Timestamp("2018-01-01 00:00:00")},
249249
"NATION": {0: "us"},
250250
"count": {0: 10024.0},
251251
"total": {0: 100006.0},
@@ -259,7 +259,7 @@ def test_add_geocode(self, geomapper):
259259
new_data,
260260
pd.DataFrame().from_dict(
261261
{
262-
"date": {
262+
"timestamp": {
263263
0: pd.Timestamp("2018-01-01"),
264264
1: pd.Timestamp("2018-01-03"),
265265
},
@@ -280,7 +280,7 @@ def test_add_geocode(self, geomapper):
280280
assert geomapper.add_geocode(self.fips_data_3, "fips", "hrr", dropna=False).isna().any().any()
281281

282282
# fips -> zip (date_col=None chech)
283-
new_data = geomapper.replace_geocode(self.fips_data_5.drop(columns=["date"]), "fips", "hrr", date_col=None)
283+
new_data = geomapper.replace_geocode(self.fips_data_5.drop(columns=["timestamp"]), "fips", "hrr", date_col=None)
284284
pd.testing.assert_frame_equal(
285285
new_data,
286286
pd.DataFrame().from_dict(
@@ -293,7 +293,7 @@ def test_add_geocode(self, geomapper):
293293
)
294294

295295
# fips -> hhs
296-
new_data = geomapper.replace_geocode(self.fips_data_3.drop(columns=["date"]),
296+
new_data = geomapper.replace_geocode(self.fips_data_3.drop(columns=["timestamp"]),
297297
"fips", "hhs", date_col=None)
298298
pd.testing.assert_frame_equal(
299299
new_data,
@@ -313,7 +313,7 @@ def test_add_geocode(self, geomapper):
313313
new_data,
314314
pd.DataFrame().from_dict(
315315
{
316-
"date": {0: pd.Timestamp("2018-01-01"), 1: pd.Timestamp("2018-01-01"),
316+
"timestamp": {0: pd.Timestamp("2018-01-01"), 1: pd.Timestamp("2018-01-01"),
317317
2: pd.Timestamp("2018-01-03"), 3: pd.Timestamp("2018-01-03")},
318318
"hhs": {0: "5", 1: "9", 2: "5", 3: "9"},
319319
"count": {0: 99.0, 1: 801.0, 2: 100.0, 3: 786.0},

_delphi_utils_python/tests/validator/test_dynamic.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def test_half_padding(self):
4949
assert new_ref_df.time_value.max() == datetime.strptime("2021-01-11",
5050
"%Y-%m-%d").date()
5151
assert new_ref_df.shape[0] == 11
52-
assert new_ref_df.loc[:, "val"].iloc[5] == 2
52+
assert new_ref_df["val"].iloc[5] == 2
5353

5454
def test_full_padding(self):
5555
validator = DynamicValidator(self.params)
@@ -71,7 +71,7 @@ def test_full_padding(self):
7171
assert new_ref_df.time_value.max() == datetime.strptime("2021-01-15",
7272
"%Y-%m-%d").date()
7373
assert new_ref_df.shape[0] == 15
74-
assert new_ref_df.loc[:, "val"].iloc[5] == 2
74+
assert new_ref_df["val"].iloc[5] == 2
7575

7676
class TestCheckRapidChange:
7777
params = {

_template_python/delphi_NAME/run.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,7 @@ def run_module(params):
4747
## aggregate & smooth
4848
## TODO: add num/prop variations if needed
4949
for sensor, smoother, geo in product(SIGNALS, SMOOTHERS, GEOS):
50-
df = mapper.replace_geocode(
51-
all_data, "zip", geo,
52-
new_col="geo_id",
53-
date_col="timestamp")
50+
df = mapper.replace_geocode(all_data, "zip", geo, new_col="geo_id")
5451
## TODO: recompute sample_size, se here if not NA
5552
df["val"] = df[["geo_id", "val"]].groupby("geo_id")["val"].transform(
5653
smoother[0].smooth

0 commit comments

Comments
 (0)