Skip to content
Permalink
Browse files

Merge pull request #19 from reichlab/issue-18-intepret-empty-as-NA

Fixed Issue 18
  • Loading branch information
Khoale1096 committed Nov 20, 2019
2 parents 74bd9d1 + 80a6221 commit a0d25ba23b97b3bed6f8b7add4866062503350eb
@@ -0,0 +1,15 @@
{
"meta":{

},
"predictions":[
{
"location":"US National",
"target":"Season onset",
"class":"Point",
"prediction":{
"value":"45"
}
}
]
}
@@ -0,0 +1,2 @@
Location,Target,Type,Unit,Bin_start_incl,Bin_end_notincl,Value
US National,Season onset,Point,week,,,45
@@ -31,7 +31,7 @@ def test_authenticate(self):
self.assertEqual(p, conn.password)
self.assertIsInstance(conn.session, ZoltarSession)
self.assertEqual(MOCK_TOKEN, conn.session.token)
post_mock.assert_called_once_with('/api-token-auth/', {'username': 'username', 'password': 'password'})
post_mock.assert_called_once_with('/api-token-auth/', {'username': 'Z_USERNAME', 'password': 'Z_PASSWORD'})


if __name__ == '__main__':
@@ -27,6 +27,14 @@ def test_json_io_dict_from_cdc_csv_file(self):
act_json_io_dict = json_io_dict_from_cdc_csv_file(cdc_csv_fp)
self.assertEqual(exp_json_io_dict, act_json_io_dict)

# test a csv file with blank cells
with open('tests/EW43-2019-FluOutlook_Mech.csv') as cdc_csv_fp, \
open('tests/EW43-2019-FluOutlook_Mech-exp-predictions.json') \
as exp_json_fp:
exp_json_io_dict = json.load(exp_json_fp)
act_json_io_dict = json_io_dict_from_cdc_csv_file(cdc_csv_fp)
self.assertEqual(exp_json_io_dict, act_json_io_dict)


def test_csv_rows_from_json_io_dict(self):
# no meta
@@ -175,6 +175,11 @@ def _cleaned_rows_from_cdc_csv_file(cdc_csv_file_fp):
.format(CDC_POINT_ROW_TYPE, CDC_BIN_ROW_TYPE))
is_point_row = (row_type == CDC_POINT_ROW_TYPE.lower())

# if blank cell, transform to NA
bin_start_incl = 'NA' if bin_start_incl == '' else bin_start_incl
bin_end_notincl = 'NA' if bin_end_notincl == '' else bin_end_notincl
value = 'NA' if value == '' else value

# use parse_value() to handle non-numeric cases like 'NA' and 'none'
bin_start_incl = parse_value(bin_start_incl)
bin_end_notincl = parse_value(bin_end_notincl)

0 comments on commit a0d25ba

Please sign in to comment.
You can’t perform that action at this time.