Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
l = -0.5 * Fit.statistic
#print("like = %.1f" % l)
if not numpy.isfinite(l):
return -1e100
return l
# run multinest
if Fit.statMethod.lower() not in BXASolver.allowed_stats:
raise RuntimeError('ERROR: not using cash (Poisson likelihood) for Poisson data! set Fit.statMethod to cash before analysing (currently: %s)!' % Fit.statMethod)
n_dims = len(self.paramnames)
resume = kwargs.pop('resume', False)
Lepsilon = kwargs.pop('Lepsilon', 0.1)
with XSilence():
self.results = solve(log_likelihood, self.prior_function, n_dims,
paramnames=self.paramnames,
outputfiles_basename=self.outputfiles_basename,
resume=resume, Lepsilon=Lepsilon,
n_live_points=n_live_points, evidence_tolerance=evidence_tolerance,
seed=-1, max_iter=0, wrapped_params=wrapped_params, **kwargs
)
self.posterior = self.results['samples']
chainfilename = '%schain.fits' % self.outputfiles_basename
store_chain(chainfilename, self.transformations, self.posterior)
xspec.AllChains.clear()
xspec.AllChains += chainfilename
# set current parameters to best fit
self.set_best_fit()
return self.results
#print "%.1f" % l
return l
except Exception as e:
print('Exception in log_likelihood function: ', e)
for i, p in enumerate(self.parameters):
print(' Parameter %10s: %f --> %f [%f..%f]' % (p.fullname, p.val, cube[i], p.min, p.max))
#import sys
#sys.exit(-127)
raise Exception("Model evaluation problem") from e
return -1e300
n_dims = len(self.parameters)
resume = kwargs.pop('resume', False)
Lepsilon = kwargs.pop('Lepsilon', 0.1)
self.results = solve(log_likelihood, prior_transform, n_dims,
paramnames=self.paramnames,
outputfiles_basename=self.outputfiles_basename,
resume=resume, Lepsilon=Lepsilon,
n_live_points=n_live_points, evidence_tolerance=evidence_tolerance,
seed=-1, max_iter=0, wrapped_params=wrapped_params, **kwargs
)
self.set_best_fit()
return self.results