diff --git a/smodels/matching/theoryPrediction.py b/smodels/matching/theoryPrediction.py index 13a2bbccf..c34aa9644 100644 --- a/smodels/matching/theoryPrediction.py +++ b/smodels/matching/theoryPrediction.py @@ -368,11 +368,12 @@ def computeStatistics(self, expected=False): # Compute likelihoods and related parameters: llhdDict = self.statsComputer.get_five_values(expected = expected, return_nll = True ) - self.cachedObjs[expected]["nll"] = llhdDict["lbsm"] - self.cachedObjs[expected]["nll_sm"] = llhdDict["lsm"] - self.cachedObjs[expected]["nllmax"] = llhdDict["lmax"] - self.cachedObjs[expected]["muhat"] = llhdDict["muhat"] - self.cachedObjs[expected]["sigma_mu"] = llhdDict["sigma_mu"] + if llhdDict not in [ None, {} ]: + self.cachedObjs[expected]["nll"] = llhdDict["lbsm"] + self.cachedObjs[expected]["nll_sm"] = llhdDict["lsm"] + self.cachedObjs[expected]["nllmax"] = llhdDict["lmax"] + self.cachedObjs[expected]["muhat"] = llhdDict["muhat"] + self.cachedObjs[expected]["sigma_mu"] = llhdDict["sigma_mu"] class TheoryPredictionsCombiner(TheoryPrediction): diff --git a/smodels/statistics/statsTools.py b/smodels/statistics/statsTools.py index cd8a35a02..48b53d045 100755 --- a/smodels/statistics/statsTools.py +++ b/smodels/statistics/statsTools.py @@ -290,6 +290,8 @@ def get_five_values ( self, expected : Union [ bool, Text ], correct, if necessary """ ret = self.maximize_likelihood ( expected = expected, return_nll = return_nll ) + if ret is None: + return {} lmax = ret['lmax'] lbsm = self.likelihood ( poi_test = 1., expected=expected, return_nll = return_nll )