Skip to content

Commit

Permalink
small fixes in docstring, formatting, type hinting in theoryPrediction
Browse files Browse the repository at this point in the history
  • Loading branch information
WolfgangWaltenberger committed Jan 17, 2024
1 parent 2a7e68c commit 7bdb714
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions smodels/matching/theoryPrediction.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from smodels.matching import clusterTools
from smodels.base.smodelsLogging import logger
from smodels.statistics.statsTools import StatsComputer
from typing import Union, Text
from typing import Union, Text, Dict
import numpy as np

__all__ = [ "TheoryPrediction", "theoryPredictionsFor", "TheoryPredictionsCombiner" ]
Expand Down Expand Up @@ -397,7 +397,7 @@ def __new__(cls,theoryPredictions: list, slhafile=None, deltas_rel=None):
def __init__(self, theoryPredictions: list, slhafile=None, deltas_rel=None):
"""
Constructor.
:param theoryPredictions: the List of theory predictions
:param slhafile: optionally, the slhafile can be given, for debugging
:param deltas_rel: relative uncertainty in signal (float).
Expand Down Expand Up @@ -562,7 +562,7 @@ def __init__(self, theoryPredictions=None, maxCond=None):
condition violation < maxCond.
"""
self._theoryPredictions = []
if theoryPredictions and isinstance(theoryPredictions,
if theoryPredictions and isinstance(theoryPredictions,
(TheoryPredictionList,list)):

if not maxCond:
Expand Down Expand Up @@ -623,16 +623,16 @@ def sortTheoryPredictions(self):
)


def theoryPredictionsFor(database, smsTopDict, maxMassDist=0.2,
useBestDataset=True, combinedResults=True,
deltas_rel=None):
def theoryPredictionsFor(database : Database, smsTopDict : Dict,
maxMassDist : float = 0.2, useBestDataset : bool = True,
combinedResults : bool = True, deltas_rel : Union[None,float] = None):
"""
Compute theory predictions for the given experimental result, using the list of
SMS in smsTopDict.
For each Txname appearing in expResult, it collects the SMS and
efficiencies, combine the SMS and compute the conditions (if exist).
:parameter expResult: expResult to be considered (ExpResult object), if list of ExpResults is given, produce theory predictions for all
:parameter database: the database with the selected experimental results
:parameter smsTopDict: dictionary of SMS, where the canonical names are keys and the TheorySMS objects are values.
(TopologyDict object)
:parameter maxMassDist: maximum mass distance for clustering SMS (float)
Expand Down Expand Up @@ -661,7 +661,7 @@ def theoryPredictionsFor(database, smsTopDict, maxMassDist=0.2,
expSMSDict = database.expSMSDict
# Compute dictionary with matches:
smsMatch = expSMSDict.getMatchesFrom(smsTopDict)

ret = []
for expResult in database.expResultList:
dataSetResults = []
Expand All @@ -672,11 +672,11 @@ def theoryPredictionsFor(database, smsTopDict, maxMassDist=0.2,
dataSetResults.append(predList)
if not dataSetResults: # no results at all?
continue

# For results with more than one dataset keep all dataset predictions
if len(dataSetResults) == 1: # only a single dataset? Easy case.
expResults = dataSetResults[0]

# if useBestDataSet=False and combinedResults=False:
elif not useBestDataset and not combinedResults:
expResults = sum(dataSetResults)
Expand Down Expand Up @@ -912,7 +912,7 @@ def _getSMSFor(dataset,smsMatch,smsDict):
sms_orig.setTestedBy(dataset.globalInfo.type)
newSMS.eff = eff
newSMS.txname = txname
newSMS.txlabel = smsLabel
newSMS.txlabel = smsLabel
smsList.append(newSMS)

return smsList
Expand Down

0 comments on commit 7bdb714

Please sign in to comment.