Skip to content

Commit 04da01b

Browse files
cont evaltype
1 parent af1659d commit 04da01b

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

smodels/statistics/speyTools.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ def translateExpectationType ( cls, expected : NllEvalType ) -> ExpectationType:
324324
aposteriori: ExpectationType.aposteriori}
325325
if expected in expectedDict:
326326
return expectedDict[expected]
327-
logger.error('%s is not a valid expectation type. Possible expectation types are True (observed), False (apriori) and "posteriori".' %expected)
327+
logger.error( f'{expected} is not a valid expectation type. Possible expectation types are True (observed), False (apriori) and "posteriori".' )
328328
return None
329329

330330
def get_five_values ( self, expected : NllEvalType,
@@ -413,7 +413,7 @@ def getBestCombinationIndex(self, data ):
413413
logger.debug( f"Workspace number {i_ws} has zero signals" )
414414
continue
415415
else:
416-
ul = self.poi_upper_limit(expected=True, model_index=i_ws)
416+
ul = self.poi_upper_limit(expected=apriori, model_index=i_ws)
417417
if ul == None:
418418
continue
419419
if ul < ulMin:

smodels/tools/caching.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
import numpy as np
1717
from collections.abc import Iterable
18+
from smodels.statistics.basicStats import observed, apriori, aposteriori, NllEvalType
1819
from functools import lru_cache, wraps
1920

2021
def roundObj(obj, digits : int):
@@ -63,13 +64,13 @@ class TestCase:
6364
def __init__ ( self ):
6465
self.bla = 0
6566
@roundCache(argname='mu',argpos=1,digits=5)
66-
def myfunc ( self, mu : float = 0., expected : Union[Text,bool] = False,
67+
def myfunc ( self, mu : float = 0., expected : NllEvalType = observed,
6768
asimov : Union[None,float] = None ):
6869
print ( "calling myfunc" )
6970
ret = mu
70-
if expected == True:
71+
if expected == apriori:
7172
ret += 10.
72-
if expected == "posteriori":
73+
if expected == aposteriori:
7374
ret += 20.
7475
if asimov != None:
7576
ret += 1000.*(asimov+1000.)
@@ -83,7 +84,7 @@ def myfunc ( self, mu : float = 0., expected : Union[Text,bool] = False,
8384
print ( test.myfunc ( 1. ) )
8485
print ( test.myfunc ( mu=1. ) )
8586
print ( test.myfunc ( mu=1. ) )
86-
print ( test.myfunc ( 1.,expected=True, asimov=0. ) )
87-
print ( test.myfunc ( 1.,expected=True, asimov=0. ) )
88-
print ( test.myfunc ( 1.,True, asimov=0. ) )
89-
print ( test.myfunc ( 1.,True, asimov=0. ) )
87+
print ( test.myfunc ( 1.,expected=apriori, asimov=0. ) )
88+
print ( test.myfunc ( 1.,expected=apriori, asimov=0. ) )
89+
print ( test.myfunc ( 1.,apriori, asimov=0. ) )
90+
print ( test.myfunc ( 1.,apriori, asimov=0. ) )

0 commit comments

Comments
 (0)