Skip to content

Commit 3d65103

Browse files
Revert "removing unittests"
This reverts commit 022a2a3.
1 parent 022a2a3 commit 3d65103

File tree

1,971 files changed

+1455518
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,971 files changed

+1455518
-0
lines changed

unittests/Makefile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
all: test
2+
3+
test:
4+
./runCompleteTestSuite.py -v -n
5+
6+
test_norecipes:
7+
./runCompleteTestSuite.py -v
8+
9+
reduced:
10+
./runCompleteTestSuite.py -r -v
11+
12+
obs:
13+
py.test -v
14+
15+
run_coverage:
16+
coverage run runCompleteTestSuite.py
17+
18+
coverage:
19+
coverage report --omit="/usr/lib/*,testFiles/scanExample/*,*/.local/*,unitTestOutput/*,test*py,test*py" -i
20+
rm -rf htmlcov/
21+
coverage html --omit="/usr/lib/*,testFiles/scanExample/*,*/.local/*,unitTestOutput/*,test*py,test*py" -i
22+
cp htmlcov/* ../../smodels.github.io/coverage/
23+
24+
notebook:
25+
ipython notebook

unittests/T1tttt_comb_default.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
smodelsOutputDefault = {'OutputStatus': {'sigmacut': 0.03, 'minmassgap': 5.0, 'maxcond': 0.2, 'ncpus': -6, 'file status': 1, 'decomposition status': 1, 'warnings': 'Input file ok', 'input file': 'testFiles/slha/T1tttt.slha', 'database version': 'unittest211', 'smodels version': '2.2.0'}, 'ExptRes': [{'maxcond': 0.0, 'theory prediction (fb)': 4.669625, 'upper limit (fb)': 0.081354, 'expected upper limit (fb)': 0.081354, 'TxNames': ['T1tttt'], 'Mass (GeV)': [[675.0, 200.0], [675.0, 200.0]], 'AnalysisID': 'CMS-SUS-16-050-agg', 'DataSetID': 'ar55', 'AnalysisSqrts (TeV)': 13.0, 'lumi (fb-1)': 35.9, 'dataType': 'efficiencyMap', 'r': 57.39884, 'r_expected': 57.39884, 'Width (GeV)': [['prompt', 'stable'], ['prompt', 'stable']], 'likelihood': 3.938979304647101e-74, 'l_max': 0.2513719, 'l_SM': 0.2513719}, {'maxcond': 0.0, 'theory prediction (fb)': 4309.035, 'upper limit (fb)': 141.1736, 'expected upper limit (fb)': None, 'TxNames': ['T1tttt'], 'Mass (GeV)': [[675.0, 200.0], [675.0, 200.0]], 'AnalysisID': 'CMS-PAS-SUS-15-002', 'DataSetID': None, 'AnalysisSqrts (TeV)': 13.0, 'lumi (fb-1)': 2.2, 'dataType': 'upperLimit', 'r': 30.52296, 'r_expected': None, 'Width (GeV)': [['prompt', 'stable'], ['prompt', 'stable']]}, {'maxcond': 0.0, 'theory prediction (fb)': 572.1689, 'upper limit (fb)': 62.581, 'expected upper limit (fb)': 92.717, 'TxNames': ['T1tttt'], 'Mass (GeV)': [[675.0, 200.0], [675.0, 200.0]], 'AnalysisID': 'CMS-PAS-SUS-12-026', 'DataSetID': None, 'AnalysisSqrts (TeV)': 8.0, 'lumi (fb-1)': 9.2, 'dataType': 'upperLimit', 'r': 9.142854, 'r_expected': 6.171133, 'Width (GeV)': [['prompt', 'stable'], ['prompt', 'stable']]}, {'maxcond': 0.0, 'theory prediction (fb)': 2.369623, 'upper limit (fb)': 0.4, 'expected upper limit (fb)': 0.433, 'TxNames': ['T1tttt'], 'Mass (GeV)': [[675.0, 200.0], [675.0, 200.0]], 'AnalysisID': 'ATLAS-CONF-2013-037', 'DataSetID': 'SRbC3', 'AnalysisSqrts (TeV)': 8.0, 'lumi (fb-1)': 20.7, 'dataType': 'efficiencyMap', 'r': 5.924058, 'r_expected': 5.472571, 'Width (GeV)': [['prompt', 'stable'], ['prompt', 'stable']], 'likelihood': 8.800609000000001e-17, 'l_max': 0.02067189, 'l_SM': 0.02067189}, {'maxcond': 0.0, 'theory prediction (fb)': 2.962771, 'upper limit (fb)': 0.5171654, 'expected upper limit (fb)': 0.3654986, 'TxNames': ['T1tttt'], 'Mass (GeV)': [[675.0, 200.0], [675.0, 200.0]], 'AnalysisID': 'CMS-SUS-13-012', 'DataSetID': '8NJetinf_1000HT1250_200MHTinf', 'AnalysisSqrts (TeV)': 8.0, 'lumi (fb-1)': 19.5, 'dataType': 'efficiencyMap', 'r': 5.728866, 'r_expected': 8.106107, 'Width (GeV)': [['prompt', 'stable'], ['prompt', 'stable']], 'likelihood': 1.949589e-18, 'l_max': 0.0265176, 'l_SM': 0.02060875}], 'CombinedRes': [{'AnalysisID': 'CMS-SUS-13-012,CMS-SUS-16-050-agg', 'r': 110.3102, 'r_expected': 116.688, 'likelihood': 7.679392482807625e-92, 'l_max': 0.008212736, 'l_SM': 0.005180459}], 'Total xsec for missing topologies (fb)': 0.0, 'missing topologies': [], 'Total xsec for missing topologies with displaced decays (fb)': 0.0, 'missing topologies with displaced decays': [], 'Total xsec for missing topologies with prompt decays (fb)': 0.0, 'missing topologies with prompt decays': [], 'Total xsec for topologies outside the grid (fb)': 0.0, 'topologies outside the grid': []}

unittests/T6bbHH_pyhf_default.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
smodelsOutputDefault = {
2+
'OutputStatus' : {
3+
'sigmacut' : 0.03,
4+
'minmassgap' : 5.0,
5+
'maxcond' : 0.2,
6+
'ncpus' : -1,
7+
'model' : 'share.models.mssm',
8+
'checkinput' : True,
9+
'doinvisible' : True,
10+
'docompress' : True,
11+
'computestatistics' : False,
12+
'testcoverage' : True,
13+
'combinesrs' : True,
14+
'file status' : 1,
15+
'decomposition status' : 1,
16+
'warnings' : 'Input file ok',
17+
'input file' : './testFiles/slha/T6bbHH_pyhf.slha',
18+
'database version' : 'unittest211',
19+
'smodels version' : '2.2.0'
20+
},
21+
'ExptRes' : [
22+
{
23+
'maxcond' : 0.0,
24+
'theory prediction (fb)' : 0.10091,
25+
'upper limit (fb)' : 0.08247307,
26+
'expected upper limit (fb)' : 0.1200876,
27+
'TxNames' : ['T6bbHH'],
28+
'Mass (GeV)' : [[1400.0, 1000.0, 60.0], [1400.0, 1000.0, 60.0]],
29+
'AnalysisID' : 'ATLAS-SUSY-2018-31',
30+
'DataSetID' : '(combined)',
31+
'AnalysisSqrts (TeV)' : 13.0,
32+
'lumi (fb-1)' : 139.0,
33+
'dataType' : 'combined',
34+
'r' : 1.223551,
35+
'r_expected' : 0.8403036,
36+
'Width (GeV)' : [[1.0, 1.0, 'stable'], [1.0, 1.0, 'stable']],
37+
'nll' : 51.35556035013835,
38+
'nll_min' : 48.38229103232457,
39+
'nll_SM' : 48.38229103232457
40+
}
41+
],
42+
'Total xsec for missing topologies (fb)' : 0.0,
43+
'missing topologies' : [],
44+
'Total xsec for missing topologies with displaced decays (fb)' : 0.0,
45+
'missing topologies with displaced decays' : [],
46+
'Total xsec for missing topologies with prompt decays (fb)' : 0.0,
47+
'missing topologies with prompt decays' : [],
48+
'Total xsec for topologies outside the grid (fb)' : 0.0,
49+
'topologies outside the grid' : []
50+
}
51+

unittests/bad_default.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
smodelsOutputDefault = {'OutputStatus': {'minmassgap': 5.0, 'input file': '/home/walten/git/smodels/inputFiles/slha/I_dont_exist.slha', 'decomposition status': -2, 'warnings': 'Unknown input type: None', 'ncpus': -1, 'maxcond': 0.2, 'smodels version': '1.1.1', 'database version': 'unittest', 'sigmacut': 0.03, 'file status': -5}}

unittests/buildPickles.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env python3
2+
3+
import glob, shutil, os
4+
5+
def rmOldPickles():
6+
files = glob.glob ( "**/*.pcl", recursive=True )
7+
files += glob.glob ( "**/.*.pcl", recursive=True )
8+
for f in files:
9+
if not "notebookTests" in f:
10+
print ( f"[buildPickles] rm {f}" )
11+
os.unlink ( f )
12+
13+
def buildDatabases():
14+
from smodels.experiment.databaseObj import Database
15+
versionfiles = glob.glob ( "*/version" )
16+
for versionfile in versionfiles:
17+
dbpath = versionfile.replace("/version","")
18+
print ( dbpath )
19+
try:
20+
db = Database ( dbpath )
21+
except Exception as e:
22+
print ( f"error: {e}" )
23+
24+
if __name__ == "__main__":
25+
rmOldPickles()
26+
buildDatabases()

unittests/checkInterpolation.ipynb

Lines changed: 185 additions & 0 deletions
Large diffs are not rendered by default.

unittests/convertNotebook2Test.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/usr/bin/env python3
2+
3+
"""
4+
.. module:: convertNotebook2Test
5+
:synopsis: Reads the cells from a notebook and store the output from each cell execution.
6+
7+
8+
.. moduleauthor:: Andre Lessa <lessa.a.p@gmail.com>
9+
10+
"""
11+
import sys
12+
import os
13+
import json
14+
import pickle
15+
16+
def getNotebookData(notebookFile,savePickle=True):
17+
18+
if not os.path.isfile(notebookFile):
19+
print('File %s not found' %notebookFile)
20+
return None
21+
22+
with open(notebookFile,'r') as f:
23+
data = json.load(f)
24+
25+
cells = data['cells']
26+
outputDict = {}
27+
for cell in cells:
28+
cell_type = cell['cell_type']
29+
if cell_type != 'code':
30+
continue
31+
cell_count = cell['execution_count']
32+
if cell_count is None:
33+
continue
34+
35+
outputList = [[outStr.replace('\n','') for outStr in c['text']]
36+
for c in cell['outputs'] if c['output_type'] == 'stream']
37+
outputDict[cell_count] = outputList
38+
39+
if savePickle:
40+
outputFile = notebookFile
41+
outputFile = outputFile.replace('.ipynb','_output.pcl')
42+
pickle.dump(outputDict,open(outputFile,'wb'))
43+
return outputDict
44+
45+
46+
if __name__ == "__main__":
47+
import argparse
48+
ap = argparse.ArgumentParser('Convert the notebook output to a pickle file to be used as a unit test')
49+
ap.add_argument('-f','--filename', help='path to the notebook file')
50+
args = ap.parse_args()
51+
52+
53+
getNotebookData(args.filename)

0 commit comments

Comments
 (0)