From d2587fd8839290ceb167ad615c2033cbe40041b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gordon=20J=2E=20K=C3=B6hn?= Date: Tue, 15 Oct 2024 17:13:55 +0200 Subject: [PATCH] clean write version --- lollipop/cli/deconvolute.py | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/lollipop/cli/deconvolute.py b/lollipop/cli/deconvolute.py index 803f512..2362da9 100755 --- a/lollipop/cli/deconvolute.py +++ b/lollipop/cli/deconvolute.py @@ -14,7 +14,7 @@ import pandas as pd import numpy as np from tqdm import tqdm, trange -from threadpoolctl import threadpool_info, ThreadpoolController, threadpool_limits +from threadpoolctl import ThreadpoolController import lollipop as ll @@ -147,11 +147,10 @@ def _deconvolute_bootstrap( List[pd.DataFrame] The deconvolution results for the location and bootstrap iterations. """ - print("Threadpool: ", threadpool_info()) - - logging.warning(threadpool_info()) + # monitor the number of threads, to prevent oversubscription on blas / cluster systmes controller = ThreadpoolController() + logging.info(f"Threading configuration:\n {controller.info()}") # deconvolution results deconv = [] @@ -238,17 +237,19 @@ def _deconvolute_bootstrap( # just run one on everything weights = {} + # define deconvolution kernel + t_kdec = ll.KernelDeconv( + temp_df2[var_dates["var_dates"][mindate] + ["undetermined"]], + temp_df2["frac"], + temp_df2["date"], + kernel=kernel(**kernel_params), + reg=regressor(**regressor_params), + confint=confint(**confint_params), + **weights, + ) + # limit the number of threads, to prevent oversubscription on blas / cluster systmes with controller.limit(limits=1, user_api='blas'): - # deconvolution - t_kdec = ll.KernelDeconv( - temp_df2[var_dates["var_dates"][mindate] + ["undetermined"]], - temp_df2["frac"], - temp_df2["date"], - kernel=kernel(**kernel_params), - reg=regressor(**regressor_params), - confint=confint(**confint_params), - **weights, - ) + # do the deconvolution t_kdec = t_kdec.deconv_all(**deconv_params) if have_confint: @@ -397,9 +398,6 @@ def deconvolute( tally_data, namefield, ): - - controller = ThreadpoolController() - logging.warning(f"Controller {controller.info()}") # load data yaml = ruamel.yaml.YAML(typ="rt")