Skip to content

Commit

Permalink
more handling of "none" cases
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewcornell committed Oct 3, 2019
1 parent 23b885e commit dcf6564
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions tests/20161023-KoTstable-20161109-small-exp-predictions.json
Expand Up @@ -4,11 +4,11 @@
{"location": "HHS Region 1", "target": "1 wk ahead", "class": "Point", "prediction": {"value": 3}},
{"location": "HHS Region 1", "target": "2 wk ahead", "class": "BinLwr", "prediction": {"lwr": [0.0, 0.1], "prob": [4.0, 5.0]}},
{"location": "HHS Region 1", "target": "2 wk ahead", "class": "Point", "prediction": {"value": 6}},
{"location": "HHS Region 10", "target": "Season onset", "class": "BinCat", "prediction": {"cat": ["1", "10", "None"], "prob": [7.0, 8.0, 9.0]}},
{"location": "HHS Region 10", "target": "Season onset", "class": "BinCat", "prediction": {"cat": ["1", "10", "none"], "prob": [7.0, 8.0, 9.0]}},
{"location": "HHS Region 10", "target": "Season onset", "class": "Point", "prediction": {"value": "10"}},
{"location": "HHS Region 10", "target": "Season peak percentage", "class": "BinLwr", "prediction": {"lwr": [0.0], "prob": [11.0]}},
{"location": "HHS Region 10", "target": "Season peak percentage", "class": "Point", "prediction": {"value": 12}},
{"location": "US National", "target": "Season peak week", "class": "BinCat", "prediction": {"cat": ["1", "10", "11"], "prob": [13.0, 14.0, 15.0]}},
{"location": "US National", "target": "Season peak week", "class": "Point", "prediction": {"value": "None"}}
{"location": "US National", "target": "Season peak week", "class": "Point", "prediction": {"value": "none"}}
]
}
2 changes: 1 addition & 1 deletion tests/20161023-KoTstable-20161109-small.cdc.csv
Expand Up @@ -14,4 +14,4 @@ HHS Region 10,Season peak percentage,Point,percent,NA,NA,12
US National,Season peak week,Bin,week,1,2,13
US National,Season peak week,Bin,week,10,11,14
US National,Season peak week,Bin,week,11,12,15
US National,Season peak week,Point,week,NA,NA,None
US National,Season peak week,Point,week,NA,NA,none
7 changes: 4 additions & 3 deletions zoltpy/cdc.py
Expand Up @@ -204,11 +204,12 @@ def _prediction_dicts_for_csv_rows(rows):
try:
if is_point_row:
# NB: point comes in as a number (see parse_value() below), but should be a string
# for Targets whose point_value_type is Target.POINT_TEXT
point_value = str(value) if target_name in BINCAT_TARGET_NAMES else value
# for Targets whose point_value_type is Target.POINT_TEXT. lower() handles 'None' -> 'none'
point_value = str(value).lower() if target_name in BINCAT_TARGET_NAMES else value
point_values.append(point_value)
elif target_name in BINCAT_TARGET_NAMES:
bincat_cats.append(str(bin_start_incl))
bin_start_incl_value = str(bin_start_incl) if target_name in BINCAT_TARGET_NAMES else bin_start_incl
bincat_cats.append(bin_start_incl_value.lower()) # lower() ""
bincat_probs.append(float(value))
elif target_name in BINLWR_TARGET_NAMES:
binlwr_lwrs.append(float(bin_start_incl))
Expand Down

0 comments on commit dcf6564

Please sign in to comment.