Skip to content
Browse files

It looks like the signature of nestRun has changed to add nest_maxIte…

…r. Also, the signatures of the likelihood

and prior functions have also changed. The cnest bridge needed to be updated.

Changes were required in cnest.c and to add maxIter into the nestRun calls and add context into the
dumper and logLike wrapper definitions. I didn't worry about passing context into the actual python functions.

There is a modification to setting n_clustering_params and wrapped_params that has nothing to do with the v2.17 changes. I think it was simply a bug. With the old
version, when you have more parameters than dimensions, you get an error that you can't have more clustering
parameters than dimensions.

Signed-off-by: Johannes Buchner <>
  • Loading branch information...
1 parent 39dc49d commit 63cd917cfd59957f32edca2cca6e3c7e4d949f61 Jessica Lu committed with
Showing with 14 additions and 10 deletions.
  1. +7 −6 multinest_bridge/cnest.c
  2. +7 −4 pymultinest/
13 multinest_bridge/cnest.c
@@ -6,10 +6,11 @@
#define LOGLIKETYPE(f) double (f)(double *Cube, int n_dim, int n_par)
#define PRIORTYPE(f) void (f)(double *Cube, int n_dim, int n_par)
-#define MULTINEST_CALLBACK(f) void (f) (double *Cube, int *ndim, int *npars, double *lnew)
+#define MULTINEST_CALLBACK(f) void (f) (double *Cube, int *ndim, int *npars, \
+ double *lnew, void *context)
#define MULTINEST_DUMPERTYPE(f) void (f)(int *nsamples, int *nlive, int *npar, \
double **physlive, double **posterior, double **paramconstr, \
- double * maxloglike, double * logz, double *logzerr)
+ double *maxloglike, double *logz, double *logzerr, void *context)
#define DUMPERTYPE(f) void (f)(int nsamples, int nlive, int npar, \
double ** physlive, double ** posterior, \
double *mean, double *std, double *best, double *map, \
@@ -20,7 +21,7 @@ extern void MULTINEST_CALL(
int *mmodal, int *ceff, int *nlive, double *tol, double *efr, int *ndims,
int *nPar, int *nClsPar, int *maxModes, int *updInt, double *Ztol,
char *root, int *seed, int *pWrap, int *fb, int *resume,
- int *outfile, int *initMPI, double *nestlogzero,
+ int *outfile, int *initMPI, double *nestlogzero, int *nestMaxIter,
int *context);
@@ -95,7 +96,7 @@ void run(
int mmodal, int ceff, int nlive, double tol, double efr, int ndims,
int nPar, int nClsPar, int maxModes, int updInt, double Ztol,
char *rootstr, int seed, int * pWrap, int fb, int resume, int outfile,
- int initMPI, double logZero, int context
+ int initMPI, double logZero, int maxIter, int context
char root[100];
@@ -116,7 +117,7 @@ void run(
MULTINEST_CALL(&mmodal, &ceff, &nlive, &tol, &efr, &ndims,
&nPar, &nClsPar, &maxModes, &updInt, &Ztol,
root, &seed, pWrap, &fb, &resume,
- &outfile, &initMPI, &logZero,
- _LogLike, dumpfunc, &context);
+ &outfile, &initMPI, &logZero, &maxIter,
+ _LogLike, dumpfunc, &context);
11 pymultinest/
@@ -15,7 +15,7 @@ def run(LogLikelihood,
max_modes = 100,
outputfiles_basename = "chains/1-", seed = -1, verbose = False,
resume = True, context = 0, write_output = True, log_zero = -1e100,
- init_MPI = True, dump_callback = None):
+ max_iter = 0, init_MPI = True, dump_callback = None):
Runs MultiNest
@@ -87,6 +87,9 @@ def Loglike(cube, ndim, nparams):
@param log_zero:
points with loglike < logZero will be ignored by MultiNest
+ @param max_iter:
+ maximum number of iterations. 0 is unlimited.
@param write_output:
write output files? This is required for analysis.
@@ -98,9 +101,9 @@ def Loglike(cube, ndim, nparams):
if n_params == None:
n_params = n_dims
if n_clustering_params == None:
- n_clustering_params = n_params
+ n_clustering_params = n_dims
if wrapped_params == None:
- wrapped_params = [0] * n_params
+ wrapped_params = [0] * n_dims
WrappedType = c_int * len(wrapped_params)
wraps = WrappedType(*wrapped_params)
@@ -139,7 +142,7 @@ def Loglike(cube, ndim, nparams):
outputfiles_basename, c_int(seed), wraps,
c_int(verbose), c_int(resume),
c_int(write_output), c_int(init_MPI),
- c_double(log_zero),
+ c_double(log_zero), c_int(max_iter),

1 comment on commit 63cd917


see #6

Please sign in to comment.
Something went wrong with that request. Please try again.