From ac8528c5847f4a517c16b5283c06d3caeae8ef5e Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Mon, 20 Dec 2021 07:19:16 +0300 Subject: Replace `NaN` with `null` in JSON string Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/partial-correlations.gmi * `NaN` is not a valid JSON value, and leads to errors in the code. This commit replaces all `NaN` values with `null`. --- gn3/api/correlation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gn3/api/correlation.py b/gn3/api/correlation.py index c0b5806..1caf31f 100644 --- a/gn3/api/correlation.py +++ b/gn3/api/correlation.py @@ -110,7 +110,7 @@ def partial_correlation(): tuple(trait_fullname(trait) for trait in args["control_traits"]), args["method"], int(args["criteria"]), args["target_db"]) response = make_response( - json.dumps(corr_results, cls=OutputEncoder), + json.dumps(corr_results, cls=OutputEncoder).replace(": NaN", ": null"), 400 if "error" in corr_results.keys() else 200) response.headers["Content-Type"] = "application/json" return response -- cgit v1.2.3