Belle II Software light-2406-ragdoll
TestStdCharged Class Reference
Inheritance diagram for TestStdCharged:
Collaboration diagram for TestStdCharged:

Public Member Functions

def test_nonesense_list (self)
 
def test_all_list (self)
 
def test_good_list (self)
 
def test_higheff (self)
 
def test_loose (self)
 
def test_percentile_eff (self)
 
def test_mostLikely_lists (self)
 

Protected Member Functions

def _check_list_name (self, target, functionname, particleloader)
 
def _check_listtype_exists (self, listtype, functions=_base_functions)
 
def _check_function_call (self, functions=_base_functions, expectedlist=stdCharged._defaultlist)
 
def _check_listtype_does_not_exist (self, listtype, functions=_base_functions)
 

Detailed Description

Test case for charged standard particle lists

Definition at line 25 of file test_std_charged.py.

Member Function Documentation

◆ _check_function_call()

def _check_function_call (   self,
  functions = _base_functions,
  expectedlist = stdCharged._defaultlist 
)
protected
check that a function works (i.e. adds a particle loader)

Definition at line 56 of file test_std_charged.py.

56 def _check_function_call(self, functions=_base_functions, expectedlist=stdCharged._defaultlist):
57 """check that a function works (i.e. adds a particle loader)"""
58 for f in functions:
59 testpath = create_path()
60 f(path=testpath)
61 self.assertEqual(
62 len(testpath.modules()), 3,
63 f"Function {f.__name__} doesn't work")
64 self.assertTrue(any(module.type() == "ParticleLoader" for module in testpath.modules()))
65 loader = testpath.modules()[0]
66 self._check_list_name(expectedlist, f.__name__, loader)
67

◆ _check_list_name()

def _check_list_name (   self,
  target,
  functionname,
  particleloader 
)
protected
Check that the list name we expect is the one that was
actually added to the ParticleLoader

Definition at line 28 of file test_std_charged.py.

28 def _check_list_name(self, target, functionname, particleloader):
29 """
30 Check that the list name we expect is the one that was
31 actually added to the ParticleLoader
32 """
33 for param in particleloader.available_params():
34 if param.name == 'decayStrings':
35 name = param.values[0].split(':')[1]
36 self.assertTrue(
37 name == target,
38 "Name: \"%s\" added by function %s, expecting \"%s\""
39 % (name, functionname, target))
40

◆ _check_listtype_does_not_exist()

def _check_listtype_does_not_exist (   self,
  listtype,
  functions = _base_functions 
)
protected
check that a given listtype function doesn't do anything

Definition at line 68 of file test_std_charged.py.

68 def _check_listtype_does_not_exist(self, listtype, functions=_base_functions):
69 """check that a given listtype function doesn't do anything"""
70 for f in functions:
71 testpath = create_path()
72 f(listtype, path=testpath)
73 self.assertEqual(
74 len(testpath.modules()), 0,
75 f"List {listtype} works with function {f.__name__}")
76 self.assertFalse(any(module.type() == "ParticleLoader" for module in testpath.modules()))
77

◆ _check_listtype_exists()

def _check_listtype_exists (   self,
  listtype,
  functions = _base_functions 
)
protected
check that a given listtype function works

Definition at line 41 of file test_std_charged.py.

41 def _check_listtype_exists(self, listtype, functions=_base_functions):
42 """check that a given listtype function works"""
43 for f in functions:
44 testpath = create_path()
45 f(listtype, path=testpath)
46 self.assertEqual(
47 len(testpath.modules()), 1 if listtype == 'all' else 3,
48 f"List {listtype} doesn't work with function {f.__name__}")
49 self.assertTrue(any(module.type() == "ParticleLoader" for module in testpath.modules()))
50
51 # now we're certain that the loader is the only module on the path,
52 # so check it was added with the ParticleList name we expect
53 loader = testpath.modules()[0]
54 self._check_list_name(listtype, f.__name__, loader)
55

◆ test_all_list()

def test_all_list (   self)
check that the builder functions all work with the all list

Definition at line 82 of file test_std_charged.py.

82 def test_all_list(self):
83 """check that the builder functions all work with the all list"""
84 self._check_listtype_exists("all")
85

◆ test_good_list()

def test_good_list (   self)
check that the builder functions all work with the good list

Definition at line 86 of file test_std_charged.py.

86 def test_good_list(self):
87 """check that the builder functions all work with the good list"""
88 self._check_listtype_exists("good")
89 # all functions may be called with no arguments: makes a "good" list
90 self._check_function_call(_base_functions)
91

◆ test_higheff()

def test_higheff (   self)
check that the builder functions all work with the higheff list

Definition at line 92 of file test_std_charged.py.

92 def test_higheff(self):
93 """check that the builder functions all work with the higheff list"""
94 self._check_listtype_exists("higheff")
95

◆ test_loose()

def test_loose (   self)
check that the builder functions all work with the loose list

Definition at line 96 of file test_std_charged.py.

96 def test_loose(self):
97 """check that the builder functions all work with the loose list"""
98 self._check_listtype_exists("loose")
99

◆ test_mostLikely_lists()

def test_mostLikely_lists (   self)
check that the builder functions work with the mostLikely lists

Definition at line 117 of file test_std_charged.py.

117 def test_mostLikely_lists(self):
118 """check that the builder functions work with the mostLikely lists"""
119 nLists = 5 # Number of ParticleLoader's expected
120 testpath = create_path()
121 stdCharged.stdMostLikely(path=testpath)
122 self.assertEqual(
123 len(testpath.modules()), 3 * nLists,
124 f"There should be {int(nLists)} fillParticleList calls")
125 self.assertTrue(any(module.type() == "ParticleLoader" for module in testpath.modules()))
126 for module in testpath.modules():
127 self._check_list_name('mostlikely', 'stdMostLikely', module)
128
129
def stdMostLikely(pidPriors=None, suffix='', custom_cuts='', path=None, writeOut=True)
Definition: stdCharged.py:593

◆ test_nonesense_list()

def test_nonesense_list (   self)
check that the builder functions fail with a nonexisting list

Definition at line 78 of file test_std_charged.py.

78 def test_nonesense_list(self):
79 """check that the builder functions fail with a nonexisting list"""
80 self._check_listtype_does_not_exist("flibble")
81

◆ test_percentile_eff()

def test_percentile_eff (   self)
check that the builder functions all work with the percentile eff lists

Definition at line 100 of file test_std_charged.py.

100 def test_percentile_eff(self):
101 """check that the builder functions all work with the percentile eff lists"""
102 for function in _base_functions:
103 eff_exists = 0
104 for ename in stdCharged._effnames:
105 cut = stdCharged._stdChargedEffCuts(stdCharged._chargednames[_base_functions.index(function)],
106 ename)
107 if 0.0 < cut < 1.0:
108 self._check_listtype_exists(ename, [function])
109 eff_exists += 1
110 else:
111 self._check_listtype_does_not_exist(ename, [function])
112 self.assertTrue(
113 eff_exists,
114 "Function: \"%s\" has no valid list based on efficiency percentile."
115 % (function.__name__))
116
def _stdChargedEffCuts(particletype, listtype)
Definition: stdCharged.py:33

The documentation for this class was generated from the following file: