From 7cedea626c77167a2fb668044b93e40a97b67711 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Tue, 8 Feb 2022 08:04:39 +0300 Subject: Merge iterations to remove unnecessary computations Do all the work in a single iteration to avoid unnecessary iterations that hamper performance. --- gn3/computations/partial_correlations.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'gn3/computations') diff --git a/gn3/computations/partial_correlations.py b/gn3/computations/partial_correlations.py index 9fcc54e..f1757f9 100644 --- a/gn3/computations/partial_correlations.py +++ b/gn3/computations/partial_correlations.py @@ -294,13 +294,11 @@ def compute_trait_info(primary_vals, control_vals, target, method): def __remove_controls_for_target_nones(cont_targ): return tuple(cont for cont, targ in cont_targ if targ is not None) - conts_targs = tuple(tuple( - zip(control, targ_vals)) for control in control_vals) datafrm = build_data_frame( primary, [targ for targ in targ_vals if targ is not None], - [__remove_controls_for_target_nones(cont_targ) - for cont_targ in conts_targs]) + [__remove_controls_for_target_nones(tuple(zip(control, targ_vals))) + for control in control_vals]) covariates = "z" if datafrm.shape[1] == 3 else [ col for col in datafrm.columns if col not in ("x", "y")] ppc = pingouin.partial_corr( -- cgit v1.2.3