Skip to content

Commit 6cc6397

Browse files
committed
fixed bug, module runs
1 parent f84d0cb commit 6cc6397

File tree

3 files changed

+20
-24
lines changed

3 files changed

+20
-24
lines changed

emr_hosp/delphi_emr_hosp/sensor.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,6 @@ def fit(y_data, first_sensor_date, geo_id, num_col="num", den_col="den"):
110110
dictionary of results
111111
112112
"""
113-
# values to keep
114-
fitting_idxs = np.where(y_data.index >= first_sensor_date)[0] # JS: WILL CHANGE
115-
116113
# backfill
117114
total_counts, total_visits = EMRHospSensor.backfill(y_data[num_col].values, y_data[den_col].values)
118115
# total_counts = pd.Series(total_counts.flatten(), name=num_col, index=y_data.index)

emr_hosp/delphi_emr_hosp/update_sensor.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ def __init__(self,
9393
), f"not enough data to produce estimates starting {self.startdate}"
9494
assert self.startdate < self.enddate, "start date >= end date"
9595
assert self.enddate <= self.dropdate, "end date > drop date"
96+
assert geo in ['county', 'state', 'msa', 'hrr'], f"{geo} is invalid, pick one of 'county', 'state', 'msa', 'hrr'"
9697
self.geo, self.parallel, self.weekday = geo, parallel, weekday
9798

9899

@@ -162,9 +163,9 @@ def update_sensor(self,
162163

163164
self.shift_dates()
164165
final_sensor_idxs = (self.burn_in_dates >= self.startdate) & (self.burn_in_dates <= self.enddate)
165-
## JS: THIS IS FINE
166166

167167
# load data
168+
## JS: If the data is in fips then can we also put it into hrr?
168169
base_geo = "hrr" if self.geo == "hrr" else "fips"
169170
data = load_combined_data(emr_filepath, claims_filepath, self.dropdate, base_geo)
170171

@@ -180,7 +181,6 @@ def update_sensor(self,
180181
if not self.parallel:
181182
for geo_id, sub_data in data_frame.groupby(level=0):
182183
sub_data.reset_index(level=0,inplace=True)
183-
del sub_data[base_geo]
184184

185185
if self.weekday:
186186
sub_data = Weekday.calc_adjustment(wd_params, sub_data)
@@ -199,7 +199,6 @@ def update_sensor(self,
199199
pool_results = []
200200
for geo_id, sub_data in data_frame.groupby(level=0,as_index=False):
201201
sub_data.reset_index(level=0, inplace=True)
202-
del sub_data[base_geo]
203202
if self.weekday:
204203
sub_data = Weekday.calc_adjustment(wd_params, sub_data)
205204

@@ -222,7 +221,7 @@ def update_sensor(self,
222221
"rates": sensor_rates,
223222
"se": sensor_se,
224223
"dates": self.sensor_dates,
225-
"geo_ids": self.unique_geo_ids,
224+
"geo_ids": unique_geo_ids,
226225
"geo_level": self.geo,
227226
"include": sensor_include,
228227
}

emr_hosp/tests/test_update_sensor.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -69,23 +69,23 @@ def test_geo_reindex(self):
6969
assert (data_frame.sum() == (4200,19000)).all()
7070

7171
def test_update_sensor(self):
72-
td = TemporaryDirectory()
73-
su_inst = EMRHospSensorUpdator(
74-
"02-01-2020",
75-
"06-01-2020",
76-
"06-12-2020",
77-
'hrr',
78-
self.parallel,
79-
self.weekday)
80-
su_inst.update_sensor(
81-
EMR_FILEPATH,
82-
CLAIMS_FILEPATH,
83-
td.name,
84-
PARAMS["static_file_dir"]
85-
)
86-
assert len(os.listdir(td.name)) == len(su_inst.sensor_dates)
87-
## JS: ADD MORE TESTS HERE
88-
td.cleanup()
72+
for geo in ["state","hrr"]:
73+
td = TemporaryDirectory()
74+
su_inst = EMRHospSensorUpdator(
75+
"02-01-2020",
76+
"06-01-2020",
77+
"06-12-2020",
78+
geo,
79+
self.parallel,
80+
self.weekday)
81+
su_inst.update_sensor(
82+
EMR_FILEPATH,
83+
CLAIMS_FILEPATH,
84+
td.name,
85+
PARAMS["static_file_dir"]
86+
)
87+
assert len(os.listdir(td.name)) == len(su_inst.sensor_dates), f"failed {geo} update sensor test"
88+
td.cleanup()
8989

9090
class TestWriteToCsv:
9191
def test_write_to_csv_results(self):

0 commit comments

Comments
 (0)