AttributeError: 'CustomSignal' object has no attribute '_loglikelihood' #54
Labels
bug
Something isn't working
enhancement
New feature or request
hackweek2022
Issues to be fixed during the 2022 Hack Week
Calling the likelihood check function seem to result in
AttributeError: 'CustomSignal' object has no attribute '_loglikelihood'
error at least in the following cases:If calling originally the star object with the same parameter vector
p
(bystar(p)
) as that which is provided to the likelihood check function (likelihood.check(None, [-3.27536126e+04], 1.0e-6,physical_points=[p])
), and not clearing the cache (likelihood.clear_cache()
) before the likelihood check or possibly not calculating the likelihood by calling the likelihood object directly first (likelihood(p)
). This happens because the likelihood check then thinks that likelihood was already calculated (and the attribute_loglikelihood
would then exist) even though it was actually not.As in the previous case, but if the parameter vector provided is out of the prior bounds, calling just first
likelihood(p)
does not help since the likelihood will not be fully calculated and the attribute_loglikelihood
will not be introduced. Clearing the cache before the likelihood check will anyway solve the problem.I would suggest either handling this error better to give a more helpful error message about the likely cause of the issue or clearing the cache always by default before doing the rest of the likelihood check (which I think would always prevent the error from happening, at least for these cases). Clearing the cache could be automatically done at the beginning of the
check()
function inLikelihood.py
by adding a line:self.clear_cache()
. Unless people think it is good to keep the possibility for cached likelihood checks if parameters are unchanged?The text was updated successfully, but these errors were encountered: