Belle II Software prerelease-10-00-00a
TestGetComparison Class Reference
Inheritance diagram for TestGetComparison:
Collaboration diagram for TestGetComparison:

Public Member Functions

 setUp (self)
 
 test_get_comparison (self)
 

Public Attributes

dict test_options
 Mapping test case -> Metaoptions.
 
list obj_pairs
 ROOT objects used to check if comparison executes.
 

Detailed Description

 Test get_comparison 

Definition at line 24 of file test_comparison.py.

Member Function Documentation

◆ setUp()

setUp ( self)
 Set up testing of get_comparison 

Definition at line 27 of file test_comparison.py.

27 def setUp(self):
28 """ Set up testing of get_comparison """
29
30 self.test_options = {
31 "chi2": "",
32 "kolmogorov": "kolmogorov",
33 "andersondarling": "andersondarling",
34 }
35 gaus_th1f = ROOT.TH1F("gaus", "gaus", 5, -3, 3)
36 gaus_th1f.FillRandom("gaus", 1000)
37 exponential_th1f = ROOT.TH1F("expo", "expo", 5, -3, 3)
38 exponential_th1f.FillRandom("expo", 1000)
39
40 self.obj_pairs: List[Tuple[ROOT.TObject, ROOT.TObject, str]] = [
41 (gaus_th1f, gaus_th1f, "equal"),
42 (gaus_th1f, exponential_th1f, "error"),
43 ]
44

◆ test_get_comparison()

test_get_comparison ( self)
 Use get_tester on the metaoptions to get the requested
comparison object and run that on two identical ROOT object.
Check that this indeed returns 'equal'.

Definition at line 45 of file test_comparison.py.

45 def test_get_comparison(self):
46 """ Use get_tester on the metaoptions to get the requested
47 comparison object and run that on two identical ROOT object.
48 Check that this indeed returns 'equal'.
49 """
50 for tester_name in self.test_options:
51 for objs in self.obj_pairs:
52 names: Tuple[str, str] = (objs[0].GetName(), objs[1].GetName())
53 with self.subTest(
54 tester=tester_name, obj1=names[0], obj2=names[1],
55 ):
56 tester = validationcomparison.get_comparison(
57 objs[0],
58 objs[1],
60 self.test_options[tester_name].split(",")
61 ),
62 )
63 print(
64 f"{names[0]}, {names[1]}: "
65 f"{tester.comparison_result_long}. "
66 f"Short result: {tester.comparison_result}. "
67 f"Expectation: {objs[2]}"
68 )
69 self.assertEqual(tester.comparison_result, objs[2])
70
71

Member Data Documentation

◆ obj_pairs

list obj_pairs
Initial value:
= [
(gaus_th1f, gaus_th1f, "equal"),
(gaus_th1f, exponential_th1f, "error"),
]

ROOT objects used to check if comparison executes.

Definition at line 40 of file test_comparison.py.

◆ test_options

dict test_options
Initial value:
= {
"chi2": "",
"kolmogorov": "kolmogorov",
"andersondarling": "andersondarling",
}

Mapping test case -> Metaoptions.

Definition at line 30 of file test_comparison.py.


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