Skip to content
Snippets Groups Projects
Commit 9f8672ee authored by Sachuk, Lina's avatar Sachuk, Lina
Browse files

Merge branch 'json_replace_nan_infinities_null' into 'master'

fixes issue #96

Closes #96

See merge request !240
parents 1cc69f57 93d86e26
No related branches found
No related tags found
1 merge request!240fixes issue #96
Pipeline #284146 passed
...@@ -47,6 +47,11 @@ def calculate_residual(reading: Reading, adjust_reference: bool = True): ...@@ -47,6 +47,11 @@ def calculate_residual(reading: Reading, adjust_reference: bool = True):
calculated = calculate( calculated = calculate(
reading=reading, adjust_reference=adjust_reference reading=reading, adjust_reference=adjust_reference
).json() ).json()
return json.loads(calculated.replace("NaN", "null")) return json.loads(
# replace non-JSON compliant float values with null string
calculated.replace("NaN", "null")
.replace("-Infinity", "null") # must replace "-Infinity" before "Infinity"
.replace("Infinity", "null")
)
except ValueError as e: except ValueError as e:
raise HTTPException(status_code=400, detail=str(e)) raise HTTPException(status_code=400, detail=str(e))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment