13from variables
import variables
as vm
17 """Test case for the variables.utils functions"""
20 _list_of_variables = [
'M',
'p']
23 """Expand the list of expected aliases by appending _{name} for each variable in the _list_of_variables"""
33 """Make sure the aliases created for given decaystring are as expected
34 Also, pass any additional keyword arguments to the create_aliases_for_selected function
38 self.assertEqual(expected, actual, f"decaystring: {decaystring}, arguments: {argk}")
45 """Make sure we get an error if the decaystring is not valid"""
46 with self.assertRaises(ValueError):
47 create_aliases_for_selected([
"p"],
"eeh <- ok")
50 """Make sure we get an error if o particle is selected"""
51 with self.assertRaises(ValueError):
52 create_aliases_for_selected([
"p"],
"B0 -> pi0")
55 """Make sure we get an error if the number of supplied prefixes doesn't
56 match the number of selected particles"""
57 with self.assertRaises(ValueError):
58 create_aliases_for_selected([
"p"],
"^B0 -> ^pi0", prefix=
"one")
59 with self.assertRaises(ValueError):
60 create_aliases_for_selected([
"p"],
"B0 -> ^pi0", prefix=[
"one",
"two"])
63 """Make sure we got an error if the supplied provided prefixes are not unique"""
64 with self.assertRaises(ValueError):
65 create_aliases_for_selected([
"p"],
"^B0 -> ^pi0", prefix=[
"mine",
"mine"])
68 """Check daughter can be selected for an specific named alias"""
69 self.
assertAliases(
'B0 -> [^D0 -> pi+ K-] pi0', [
'dzero'], prefix=
'dzero')
72 """Check mother and daughter can be selected for an specific named alias"""
73 self.
assertAliases(
'^B0 -> [^D0 -> pi+ ^K-] pi0', [
'MyB',
'MyD',
'MyK'], prefix=[
'MyB',
'MyD',
'MyK'])
76 """Check daughter can be selected w/o an specific named alias"""
77 self.
assertAliases(
'B0 -> [^D0 -> ^pi+ ^K-] pi0', [
'd0',
'd0_d0',
'd0_d1'], use_names=
False)
80 """Check daughter can be selected w/o an specific named alias"""
81 self.
assertAliases(
'^B0 -> pi0 ^pi0', [
'',
'd1'], use_names=
False)
83 self.
assertAliases(
'^B0 -> pi0 ^pi0', [
'',
'd1'], use_names=
False, use_relative_indices=
True)
86 """Check granddaughter can be selected for an automatic name alias"""
90 """Check multiple granddaughters can be selected for automatic name aliases"""
92 'B0 -> [D0 -> ^pi+ ^pi- ^pi0] ^pi0',
101 """ check decay-string-of-doom with automatic names """
103 "^B0 -> [D0 -> ^pi+ ^pi-] [D+ -> ^pi+ pi0] [D0 -> ^pi+ ^pi-] [K- -> ^pi+ ^pi-] ^pi+ ^pi- pi0",
118 """ check decay-string-of-doom with automatic names and relative indexing"""
120 "^B0 -> [D0 -> ^pi+ ^pi-] [D+ -> ^pi+ pi0] [D0 -> ^pi+ ^pi-] [K- -> ^pi+ ^pi-] ^pi+ ^pi- pi0",
132 ], use_relative_indices=
True)
135 """ check decay-string-of-doom with automatic names and forced indices"""
137 "^B0 -> [D0 -> ^pi+ ^pi-] [D+ -> ^pi+ pi0] [D0 -> ^pi+ ^pi-] [K- -> ^pi+ ^pi-] ^pi+ ^pi- pi0",
149 ], always_include_indices=
True)
152 """ check decay-string-of-doom with automatic names, relative indexing and forced indices"""
154 "^B0 -> [D0 -> ^pi+ ^pi-] [D+ -> ^pi+ pi0] [D0 -> ^pi+ ^pi-] [K- -> ^pi+ ^pi-] ^pi+ ^pi- pi0",
166 ], use_relative_indices=
True, always_include_indices=
True)
169 """ check decay-string-of-doom w/o automatic names """
171 "^B0 -> [D0 -> ^pi+ ^pi-] [D+ -> ^pi+ pi0] [D0 -> ^pi+ ^pi-] [K- -> ^pi+ ^pi-] ^pi+ ^pi- pi0",
186 """ check decay-string-of-doom w/o automatic names and make sure relative indexing is **not** honored"""
188 "^B0 -> [D0 -> ^pi+ ^pi-] [D+ -> ^pi+ pi0] [D0 -> ^pi+ ^pi-] [K- -> ^pi+ ^pi-] ^pi+ ^pi- pi0",
200 ], use_names=
False, use_relative_indices=
True)
203 """ check if the indexing works with more than two ... """
205 "B0 -> [D+ -> [K+ -> ^pi+]] [D+ -> [K+ -> ^pi+]] [D+ -> [K+ -> ^pi+]]",
213 """ check if the indexing works with more than two ... """
215 "B0 -> [D+ -> [K+ -> ^pi+]] [D+ -> [K+ -> ^pi+]] [D+ -> [K+ -> ^pi+]] [D+ -> [K+ -> ^pi+]]",
223 "B0 -> [D+ -> [K+ -> pi+]] [D+ -> [K+ -> ^pi+]] [D+ -> [^K+ -> pi+]] [D+ -> [K+ -> ^pi+]]",
230 "B0 -> [D+ -> [K+ -> pi+]] [D+ -> [K+ -> ^pi+]] [D+ -> [^K+ -> pi+]] [D+ -> [K+ -> ^pi+]]",
235 ], use_relative_indices=
True)
238 """Test many many children"""
240 "B0 -> e+:0 ^e+:1 ^e+:2 e+:3 ^e+:4 e+:5 ^e+:6 mu+:7 ^mu+:8 mu+:9 ^mu+:10 ^mu+:11 mu+:12",
252 """Test many many children with relative indices"""
254 "B0 -> e+:0 ^e+:1 ^e+:2 e+:3 ^e+:4 e+:5 ^e+:6 mu+:7 ^mu+:8 mu+:9 ^mu+:10 ^mu+:11 mu+:12",
263 ], use_relative_indices=
True)
266 """Test many many children without names"""
267 for use_relative_indices
in True,
False:
268 for always_include_indices
in True,
False:
270 "B0 -> e+:0 ^e+:1 ^e+:2 e+:3 ^e+:4 e+:5 ^e+:6 mu+:7 ^mu+:8 mu+:9 ^mu+:10 ^mu+:11 mu+:12",
280 use_relative_indices=use_relative_indices,
281 always_include_indices=always_include_indices,
285 """Select a decay with the inclusive particle marker"""
289 """Print all aliases as a final check"""
293if __name__ ==
'__main__':
def test_wrong_decaystring(self)
to add to the tests here, please add a test_something_something for you favourite complicated decay s...
def test_ohsomany_autonamed_relative(self)
def test_autoindex_allindexed_relative(self)
def test_ohsomany_autonamed(self)
def test_unnamed_daughter(self)
def test_named_daughter(self)
def test_named_mother_and_daughters(self)
def test_autoindex_relative(self)
def test_unnamed_mother(self)
def _expand_expected(self, expected)
def test_ohsomany_indexed(self)
def test_indexed_relativeignored(self)
def test_number_of_prefix_mismatch(self)
def test_autoindex_allindexed(self)
def test_autonamed_granddaughter(self)
def test_prefixes_repeated(self)
def test_no_particle_selected(self)
list _list_of_variables
list of variables to test
def test_multiple_autoname_granddaughters(self)
def assertAliases(self, decaystring, expected, **argk)