Skip to content

Commit 2b88a7a

Browse files
committed
changes in compliance with #205
1 parent d3270c9 commit 2b88a7a

File tree

5 files changed

+34
-32
lines changed

5 files changed

+34
-32
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
"""
2+
CONTAINS SIGNAL REGISTRY
3+
"""
4+
COVIDNET = "covidnet"
5+
SIGNALS = [COVIDNET]

cdc_covidnet/delphi_cdc_covidnet/update_sensor.py

Lines changed: 25 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,11 @@
1313
import pandas as pd
1414

1515
from delphi_utils import read_params
16-
from delphi_epidata import Epidata
17-
16+
import covidcast
1817
from .api_config import APIConfig
1918
from .covidnet import CovidNet
2019
from .geo_maps import GeoMaps
21-
22-
23-
SIGNALS = ["covidnet"]
20+
from .constants import SIGNALS
2421

2522

2623
def write_to_csv(data: pd.DataFrame, out_name: str, output_path: str):
@@ -114,48 +111,46 @@ def add_prefix(signal_names, wip_signal, prefix: str):
114111
prefix : 'wip_'
115112
prefix for new/non public signals
116113
wip_signal : List[str] or bool
117-
Either takes a list of wip signals: [], OR
118-
incorporated all signals in the registry: True OR
119-
no signals: False
114+
a list of wip signals: [], OR
115+
all signals in the registry: True OR
116+
only signals that have never been published: False
120117
Returns
121118
-------
122119
List of signal names
123120
wip/non wip signals for further computation
124121
"""
125122

126-
if wip_signal in ("", False):
127-
return signal_names
128-
elif wip_signal and isinstance(wip_signal, bool):
123+
if wip_signal is True:
124+
return [prefix + signal for signal in signal_names]
125+
if isinstance(wip_signal, list):
126+
make_wip = set(wip_signal)
127+
return [
128+
(prefix if signal in make_wip else "") + signal
129+
for signal in signal_names
130+
]
131+
if wip_signal in {False, ""}:
129132
return [
130-
(prefix + signal) if public_signal(signal)
131-
else signal
133+
signal if public_signal(signal)
134+
else prefix + signal
132135
for signal in signal_names
133136
]
134-
elif isinstance(wip_signal, list):
135-
for signal in wip_signal:
136-
if public_signal(signal):
137-
signal_names.append(prefix + signal)
138-
signal_names.remove(signal)
139-
return signal_names
140-
else:
141-
raise ValueError("Supply True | False or '' or [] | list()")
137+
raise ValueError("Supply True | False or '' or [] | list()")
142138

143139

144140
def public_signal(signal_):
145-
"""Checks if the signal name is already public using Epidata
141+
"""Checks if the signal name is already public using COVIDcast
146142
Parameters
147143
----------
148144
signal_ : str
149145
Name of the signal
150146
Returns
151147
-------
152148
bool
153-
True if the signal is not present
154-
False if the signal is present
149+
True if the signal is present
150+
False if the signal is not present
155151
"""
156-
epidata_df = Epidata.covidcast_meta()
157-
for index in range(len(epidata_df['epidata'])):
158-
if 'signal' in epidata_df['epidata'][index]:
159-
if epidata_df['epidata'][index]['signal'] == signal_:
160-
return False
161-
return True
152+
epidata_df = covidcast.metadata()
153+
for index in range(len(epidata_df)):
154+
if epidata_df['signal'][index] == signal_:
155+
return True
156+
return False

cdc_covidnet/params.json.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
"start_date": "2020-03-07",
66
"end_date": "",
77
"parallel": false,
8-
"wip_signal": ""
8+
"wip_signal": []
99
}

cdc_covidnet/setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
"pytest-cov",
99
"pylint",
1010
"delphi-utils",
11-
"requests"
11+
"requests",
12+
"covidcast"
1213
]
1314

1415
setup(

cdc_covidnet/tests/params.json.template

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@
55
"start_date": "2020-03-07",
66
"end_date": "",
77
"parallel": true
8+
"wip_signal": []
89
}

0 commit comments

Comments
 (0)