JohannesBuchner / PyMultiNest

Pythonic Bayesian inference and visualization for the MultiNest Nested Sampling Algorithm and PyCuba's cubature algorithms.
http://johannesbuchner.github.io/PyMultiNest/
Other
191 stars 87 forks source link

Q: why is n_params necessary? #240

Closed pcubillos closed 11 months ago

pcubillos commented 11 months ago

Hi, just a question in solve() function: I guess I don't really understand why line 43 is necessary if the SafePrior() function provides the nparams argument? Shouldn't n_params be the same? https://github.com/JohannesBuchner/PyMultiNest/blob/e82832cfeeb9b223b03063d4cc8d37e3b1837c85/pymultinest/solve.py#L41-L47

Thanks.

JohannesBuchner commented 11 months ago

I think the issue was that you can get segfaults if the integer variable behind ndim or nparams gets garbage-collected by python. see https://github.com/JohannesBuchner/PyMultiNest/issues/5 Accessing the python variable always works around that, but yes, probably line 43 could be pulled out of the function.

pcubillos commented 11 months ago

Ahh, I see. Thanks for the explanation and link.