diff options
| author | Gertjan van den Burg <gertjanvandenburg@gmail.com> | 2019-09-05 16:21:27 +0100 |
|---|---|---|
| committer | Gertjan van den Burg <gertjanvandenburg@gmail.com> | 2019-09-05 16:21:27 +0100 |
| commit | cb7910c66d81e457a4e985cac5b6de0ec7f82e06 (patch) | |
| tree | 87671b02d748aefa61127a1da318996eebb30487 /app | |
| parent | Add check for use of null in datasets (diff) | |
| download | AnnotateChange-cb7910c66d81e457a4e985cac5b6de0ec7f82e06.tar.gz AnnotateChange-cb7910c66d81e457a4e985cac5b6de0ec7f82e06.zip | |
Add check for missing values in multidimensional data
Diffstat (limited to 'app')
| -rw-r--r-- | app/utils/datasets.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/app/utils/datasets.py b/app/utils/datasets.py index 4341467..887ad0f 100644 --- a/app/utils/datasets.py +++ b/app/utils/datasets.py @@ -18,6 +18,7 @@ import hashlib import json import jsonschema import logging +import math import os from flask import current_app @@ -65,11 +66,18 @@ def validate_dataset(filename): if None in data["time"]["raw"]: return "Null is not supported in time axis. Use 'NaN' instead." + has_missing = False for var in data["series"]: if len(var["raw"]) != data["n_obs"]: return "Number of observations doesn't match for %s" % var["label"] if None in var["raw"]: return "Null is not supported in series. Use 'NaN' instead." + has_missing = has_missing or any(map(math.isnan, var["raw"])) + + # this doesn't happen in any dataset yet, so let's not implement it until + # we need it. + if data["n_dim"] > 1 and has_missing: + return "Missing values are not yet supported for multidimensional data" return None @@ -139,6 +147,8 @@ def load_data_for_chart(name, known_md5): with open(target_filename, "rb") as fid: data = json.load(fid) - chart_data = {"time": data["time"] if "time" in data else None, "values": - data["series"]} + chart_data = { + "time": data["time"] if "time" in data else None, + "values": data["series"], + } return {"chart_data": chart_data} |
