From ff9ef95ef55b004d75afa49044285e92874950f9 Mon Sep 17 00:00:00 2001 From: "Michael J. Williams" Date: Thu, 16 Oct 2025 17:48:56 +0100 Subject: [PATCH 1/3] ENH: add npool_post_process --- bilby/core/sampler/__init__.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/bilby/core/sampler/__init__.py b/bilby/core/sampler/__init__.py index 086e69388..2c2eb82a2 100644 --- a/bilby/core/sampler/__init__.py +++ b/bilby/core/sampler/__init__.py @@ -151,13 +151,13 @@ def run_sampler( injection_parameters=None, conversion_function=None, plot=False, - default_priors_file=None, clean=None, meta_data=None, save=True, gzip=False, result_class=None, npool=1, + npool_post_process=None, **kwargs, ): """ @@ -196,9 +196,6 @@ def run_sampler( This function should take one positional argument, a dictionary or pandas dataframe and three optional arguments: the likelihood, prior dict, and an integer :code:`npool` to allow parallelisation. - default_priors_file: str - If given, a file containing the default priors; otherwise defaults to - the bilby defaults for a binary black hole. clean: bool If given, override the command line interface `clean` option. meta_data: dict @@ -219,6 +216,10 @@ def run_sampler( npool: int An integer specifying the available CPUs to create pool objects for parallelization. + npool_post_process: int, optional + An integer specifying the available CPUs to use during the + post-processing step. If None, will use the value of npool or + check for sampler specific post-processing npool keys in kwargs. **kwargs: All kwargs are passed directly to the samplers `run` function @@ -349,11 +350,21 @@ def run_sampler( # Check if the posterior has already been created if getattr(result, "_posterior", None) is None: + if npool_post_process is None: + from .base_sampler import Sampler + + for key in Sampler.npool_post_process_keys: + if key in kwargs: + npool_post_process = kwargs[key] + break + else: + npool_post_process = npool + result.samples_to_posterior( likelihood=likelihood, priors=result.priors, conversion_function=conversion_function, - npool=npool, + npool=npool_post_process, ) if save: From 46af5fe0f815a0a8cb56f66e9e1c8f72ecd9d31e Mon Sep 17 00:00:00 2001 From: "Michael J. Williams" Date: Thu, 16 Oct 2025 20:23:38 +0100 Subject: [PATCH 2/3] BUG: fix import --- bilby/core/sampler/__init__.py | 1 - 1 file changed, 1 deletion(-) diff --git a/bilby/core/sampler/__init__.py b/bilby/core/sampler/__init__.py index 2c2eb82a2..842ea11fb 100644 --- a/bilby/core/sampler/__init__.py +++ b/bilby/core/sampler/__init__.py @@ -351,7 +351,6 @@ def run_sampler( # Check if the posterior has already been created if getattr(result, "_posterior", None) is None: if npool_post_process is None: - from .base_sampler import Sampler for key in Sampler.npool_post_process_keys: if key in kwargs: From 8bf0e1ca64db9663c835991ac85c6bc92ffc4c21 Mon Sep 17 00:00:00 2001 From: "Michael J. Williams" Date: Fri, 17 Oct 2025 09:56:11 +0100 Subject: [PATCH 3/3] BUG: fix equiv keys --- bilby/core/sampler/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bilby/core/sampler/__init__.py b/bilby/core/sampler/__init__.py index 842ea11fb..9d252139e 100644 --- a/bilby/core/sampler/__init__.py +++ b/bilby/core/sampler/__init__.py @@ -352,7 +352,7 @@ def run_sampler( if getattr(result, "_posterior", None) is None: if npool_post_process is None: - for key in Sampler.npool_post_process_keys: + for key in Sampler.npool_equiv_kwargs: if key in kwargs: npool_post_process = kwargs[key] break