From ff463fd79c76be344fe8d01e17202db010a5018d Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Mon, 3 Jan 2022 13:15:29 +0300 Subject: Remove all pairs with 'None' as the value * Remove all key-value pairs whose value is None. --- gn3/computations/partial_correlations.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'gn3/computations') diff --git a/gn3/computations/partial_correlations.py b/gn3/computations/partial_correlations.py index 13def5e..a298ff7 100644 --- a/gn3/computations/partial_correlations.py +++ b/gn3/computations/partial_correlations.py @@ -540,6 +540,8 @@ def trait_for_output(trait): pair just to indicate it does not exist. """ def __nan_to_none__(val): + if val is None: + return None if math.isnan(val) or numpy.isnan(val): return None return val @@ -581,14 +583,7 @@ def trait_for_output(trait): "tissue_corr": __nan_to_none__(trait.get("tissue_corr")), "tissue_p_value": __nan_to_none__(trait.get("tissue_p_value")) } - return { - key: val - for key, val in trait.items() - if ( - val is not None - or key in ( - "partial_corr_p_value", "corr", "corr_p_value", "rank_order", - "delta", "l_corr", "tissue_corr", "tissue_p_value"))} + return {key: val for key, val in trait.items() if val is not None} def partial_correlations_entry(# pylint: disable=[R0913, R0914, R0911] conn: Any, primary_trait_name: str, -- cgit v1.2.3