Skip to content

Commit

Permalink
added spey interface as hidden feature
Browse files Browse the repository at this point in the history
  • Loading branch information
WolfgangWaltenberger committed Jan 20, 2025
2 parents 131ccaf + fe73f07 commit 7648cd7
Show file tree
Hide file tree
Showing 3 changed files with 664 additions and 3 deletions.
3 changes: 2 additions & 1 deletion smodels/base/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
## place to keep the pointer to the model file (default = mssm)
modelFile="smodels.share.models.mssm"

_experimental = { "truncatedgaussians": False } ## experimental features
_experimental = { "truncatedgaussians": False,
"spey": False } ## experimental features

_deltas_rel_default = .2 ## the default relative error on the signal strength

Expand Down
14 changes: 12 additions & 2 deletions smodels/matching/theoryPrediction.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from smodels.matching.exceptions import SModelSMatcherError as SModelSError
from smodels.matching import clusterTools
from smodels.base.smodelsLogging import logger
from smodels.statistics.statsTools import StatsComputer
from typing import Union, Text, Dict
import numpy as np

Expand Down Expand Up @@ -144,6 +143,11 @@ def setStatsComputer(self):
to define a statistical computer (upper limit result or no expected
upper limits), set the computer to 'N/A'.
"""
from smodels.base import runtime
if runtime._experimental["spey"]:
from smodels.statistics.speyTools import SpeyComputer as StatsComputer
else:
from smodels.statistics.statsTools import StatsComputer

if self.dataType() == "upperLimit":
from smodels.base.runtime import experimentalFeature
Expand Down Expand Up @@ -373,7 +377,8 @@ def computeStatistics(self, expected=False):
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 "sigma_mu" in llhdDict:
self.cachedObjs[expected]["sigma_mu"] = llhdDict["sigma_mu"]


class TheoryPredictionsCombiner(TheoryPrediction):
Expand Down Expand Up @@ -522,6 +527,11 @@ def setStatsComputer(self):
if any(tp.statsComputer == 'N/A' for tp in self.theoryPredictions):
computer = 'N/A'
else:
from smodels.base import runtime
if runtime._experimental["spey"]:
from smodels.statistics.speyTools import SpeyComputer as StatsComputer
else:
from smodels.statistics.statsTools import StatsComputer
computer = StatsComputer.forAnalysesComb(self.theoryPredictions, self.deltas_rel)

self._statsComputer = computer
Expand Down
Loading

0 comments on commit 7648cd7

Please sign in to comment.