Skip to content

Commit 3b4360c

Browse files
authored
Merge pull request #732 from cmu-delphi/remove-wip
Remove public signal check from signal prefix
2 parents 753c688 + e0379e5 commit 3b4360c

File tree

7 files changed

+11
-43
lines changed

7 files changed

+11
-43
lines changed

_delphi_utils_python/delphi_utils/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@
1111
from .logger import get_structured_logger
1212
from .geomap import GeoMapper
1313
from .smooth import Smoother
14-
from .signal import add_prefix, public_signal
14+
from .signal import add_prefix
1515

1616
__version__ = "0.1.0"
Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""Functions for understanding and creating signal names."""
2-
import covidcast
2+
33

44
def add_prefix(signal_names, wip_signal, prefix="wip_"):
55
"""Add prefix to signal if there is a WIP signal.
@@ -28,29 +28,5 @@ def add_prefix(signal_names, wip_signal, prefix="wip_"):
2828
for signal in signal_names
2929
]
3030
if wip_signal in {False, ""}:
31-
return [
32-
signal if public_signal(signal)
33-
else prefix + signal
34-
for signal in signal_names
35-
]
31+
return signal_names
3632
raise ValueError("Supply True | False or '' or [] | list()")
37-
38-
39-
def public_signal(signal):
40-
"""Check if the signal name is already public using COVIDcast.
41-
42-
Parameters
43-
----------
44-
signal : str
45-
Name of the signal
46-
Returns
47-
-------
48-
bool
49-
True if the signal is present
50-
False if the signal is not present
51-
"""
52-
epidata_df = covidcast.metadata()
53-
for index in range(len(epidata_df)):
54-
if epidata_df["signal"][index] == signal:
55-
return True
56-
return False

_delphi_utils_python/tests/test_signal.py

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import pandas as pd
55
import pytest
6-
from delphi_utils.signal import add_prefix, public_signal
6+
from delphi_utils.signal import add_prefix
77

88
# Constants for mocking out the call to `covidcast.metadata` within `public_signal()`.
99
PUBLIC_SIGNALS = ["sig1", "sig2", "sig3"]
@@ -26,15 +26,7 @@ def test_invalid_prefix_input(self):
2626
with pytest.raises(ValueError):
2727
add_prefix(None, None)
2828

29-
@patch("covidcast.metadata")
30-
def test_add_prefix_to_non_public(self, metadata):
31-
"""Tests that `add_prefix()` derives work-in-progress names for non-public signals."""
32-
metadata.return_value = PUBLIC_SIGNALS_FRAME
33-
assert add_prefix(["sig0", "sig1"], False, prefix="wip_") == ["wip_sig0", "sig1"]
34-
35-
@patch("covidcast.metadata")
36-
def test_public_signal(self, metadata):
37-
"""Tests that `public_signal()` identifies public vs. private signals."""
38-
metadata.return_value = PUBLIC_SIGNALS_FRAME
39-
assert not public_signal("sig0")
40-
assert public_signal("sig2")
29+
def test_add_no_prefix(self):
30+
"""Tests that `add_prefix()` doesn't affect signals if `wip_signals` is False or ''."""
31+
assert add_prefix(["sig0", "sig1"], False, prefix="wip_") == ["sig0", "sig1"]
32+
assert add_prefix(["sig0", "sig1"], "", prefix="wip_") == ["sig0", "sig1"]

cdc_covidnet/tests/test_run.py

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

99
class TestRun:
1010
def test_match_old_to_new_output(self):
11-
output_fnames = ["202010_state_wip_covidnet.csv", "202011_state_wip_covidnet.csv"]
11+
output_fnames = ["202010_state_covidnet.csv", "202011_state_covidnet.csv"]
1212
cached_files = [
1313
"networkid_2_catchmentid_11.json",
1414
"networkid_2_catchmentid_14.json",

cdc_covidnet/tests/test_update_sensor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,11 @@ def test_syn_update_sensor(self):
9090
assert pd.isna(hosp_df["sample_size"]).all()
9191

9292
# Check actual files generated
93-
expected_files = ["202010_state_wip_covidnet.csv", "202011_state_wip_covidnet.csv"]
93+
expected_files = ["202010_state_covidnet.csv", "202011_state_covidnet.csv"]
9494
expected_files = [join(temp_dir, exp_file) for exp_file in expected_files]
9595
for exp_file in expected_files:
9696
assert exists(exp_file)
97-
assert not exists("202012_state_wip_covidnet.csv")
97+
assert not exists("202012_state_covidnet.csv")
9898

9999
for i, exp_file in enumerate(expected_files):
100100
data = pd.read_csv(exp_file)

0 commit comments

Comments
 (0)