Skip to content

Commit 8e18815

Browse files
committed
Fix test
Test dataframe had time_value in the wrong type, should be datetime.date
1 parent 7bbd515 commit 8e18815

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

_delphi_utils_python/delphi_utils/validator/dynamic.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -183,18 +183,18 @@ def check_na_vals(self, geo_sig_df, geo_type, signal_type, report):
183183
Returns:
184184
- None
185185
"""
186-
def replace_first_six(df):
186+
def replace_first_six(df, start_date):
187187
x = df.val.isnull()
188188
# First 6 days have to be null
189189
x.iloc[:6] = False
190-
return df.time_value[x]
190+
df = df[x]
191+
return df.time_value[df.time_value >= start_date]
191192

192193
grouped_df = geo_sig_df.groupby('geo_id')
193-
error_df = grouped_df.apply(replace_first_six)
194+
error_df = grouped_df.apply(replace_first_six,
195+
start_date = self.params.time_window.start_date)
194196

195197
if not error_df.empty:
196-
error_df = error_df[error_df.time_value >=
197-
self.params.time_window.start_date]
198198
for index, value in error_df.iteritems():
199199
report.add_raised_error(
200200
ValidationFailure("check_val_missing",

_delphi_utils_python/delphi_utils/validator/validate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def validate(self):
5757
report = ValidationReport(self.suppressed_errors, self.data_source, self.dry_run)
5858
frames_list = load_all_files(self.export_dir, self.time_window.start_date,
5959
self.time_window.end_date)
60-
#self.static_validation.validate(frames_list, report)
60+
self.static_validation.validate(frames_list, report)
6161
all_frames = aggregate_frames(frames_list)
6262
self.dynamic_validation.validate(all_frames, report)
6363
return report

_delphi_utils_python/tests/validator/test_dynamic.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,8 @@ def test_missing(self):
120120
data = {"val": [np.nan] * 15, "geo_id": [0,1] * 7 + [2],
121121
"time_value": ["2021-08-30"] * 14 + ["2021-05-01"]}
122122
df = pd.DataFrame(data)
123-
#df.set_index(range(7), inplace=True)
123+
df.time_value = (pd.to_datetime(df.time_value)).dt.date
124124
validator.check_na_vals(df, "geo", "signal", report)
125-
import pdb
126-
pdb.set_trace()
127125

128126
assert len(report.raised_errors) == 2
129127
assert report.raised_errors[0].check_name == "check_val_missing"

0 commit comments

Comments
 (0)