PyAutoFit: DynestyDynamic raises OverflowError (int too large to convert to C long) when run without an output path #28
|
Package: PyAutoFit ( What happens
import numpy as np
import autofit as af
class Gaussian:
def __init__(self, centre=0.0, normalization=1.0, sigma=1.0):
self.centre, self.normalization, self.sigma = centre, normalization, sigma
class Analysis(af.Analysis):
def __init__(self, data, x):
super().__init__()
self.data, self.x = data, x
def log_likelihood_function(self, instance):
m = instance.normalization * np.exp(-0.5 * ((self.x - instance.centre) / instance.sigma) ** 2)
return -0.5 * np.sum((self.data - m) ** 2 / 0.1 ** 2)
x = np.linspace(-5, 5, 50)
data = 2.0 * np.exp(-0.5 * (x / 1.5) ** 2)
model = af.Model(Gaussian)
model.centre = af.UniformPrior(-2, 2)
model.normalization = af.UniformPrior(0, 5)
model.sigma = af.UniformPrior(0.1, 4)
search = af.DynestyDynamic(nlive_init=50) # no name -> NullPaths
search.fit(model=model, analysis=Analysis(data, x))Giving the search a Cause
Proposed fixReturn Branch: https://github.com/samlange04/PyAutoFit/tree/fix/dynesty-dynamic-nullpaths-overflow. With it applied the script above runs to completion, and the fix comes with a regression test parametrised over both dynesty searches. |
Replies: 2 comments
|
Give the search a name until the patch is merged: search = af.DynestyDynamic(name="gauss", nlive_init=50)With no name, the call budget is a huge number ( |
|
Hi @samlange04, thank you for another excellent report, with a reproducer that runs as written. The diagnosis is spot on: our |
Hi @samlange04, thank you for another excellent report, with a reproducer that runs as written. The diagnosis is spot on: our
int(1e99)sentinel overflows dynesty'smaxcall - ncallagainst a numpy int64 in the dynamic sampler, andsys.maxsizematches dynesty's own unbounded sentinel. PR #1658 (with its regression test) is merged intomainand will ship in the next release. Until then, giving the search aname=works around it, as @xop01 kindly pointed out (thanks!).