nessai.utils.multiprocessing

Utilities related to multiprocessing.

Module Contents

Functions

initialise_pool_variables(model)

Prepare the model for use with a multiprocessing pool.

log_likelihood_wrapper(x)

Wrapper for the log-likelihood for use with multiprocessing.

get_n_pool(pool)

Determine the number of processes in a multiprocessing pool.

Attributes

logger

nessai.utils.multiprocessing.logger
nessai.utils.multiprocessing.initialise_pool_variables(model)

Prepare the model for use with a multiprocessing pool.

Makes a global copy of the model. Should be called before initialising a pool or passed to the initializer argument with the model as one of the initargs.

Parameters
modelnessai.model.Model

Model to be copied to a global variable.

nessai.utils.multiprocessing.log_likelihood_wrapper(x)

Wrapper for the log-likelihood for use with multiprocessing.

Should be used alongside nessai.utils.multiprocessing.initialise_pool_variables()

Parameters
xnumpy.ndarray

Array of samples.

Returns
numpy.ndarray

Array of log-likelihoods.

nessai.utils.multiprocessing.get_n_pool(pool)

Determine the number of processes in a multiprocessing pool.

Parameters
poolobject

Multiprocessing pool or similar.