14 from variables
import variables
as vm
18 """Test case for the variables.utils functions"""
21 _list_of_variables = [
'M',
'p']
24 """Expand the list of expected aliases by appending _{name} for each variable in the _list_of_variables"""
34 """Make sure the aliases created for given decaystring are as expected
35 Also, pass any additional keyword arguments to the create_aliases_for_selected function
38 actual = create_aliases_for_selected(self.
_list_of_variables_list_of_variables, decaystring, **argk)
39 self.assertEqual(expected, actual, f
"decaystring: {decaystring}, arguments: {argk}")
46 """Make sure we get an error if the decaystring is not valid"""
47 with self.assertRaises(ValueError):
48 create_aliases_for_selected([
"p"],
"eeh <- ok")
51 """Make sure we get an error if o particle is selected"""
52 with self.assertRaises(ValueError):
53 create_aliases_for_selected([
"p"],
"B0 -> pi0")
56 """Make sure we get an error if the number of supplied prefixes doesn't
57 match the number of selected particles"""
58 with self.assertRaises(ValueError):
59 create_aliases_for_selected([
"p"],
"^B0 -> ^pi0", prefix=
"one")
60 with self.assertRaises(ValueError):
61 create_aliases_for_selected([
"p"],
"B0 -> ^pi0", prefix=[
"one",
"two"])
64 """Make sure we got an error if the supplied provided prefixes are not unique"""
65 with self.assertRaises(ValueError):
66 create_aliases_for_selected([
"p"],
"^B0 -> ^pi0", prefix=[
"mine",
"mine"])
69 """Check daughter can be selected for an specific named alias"""
70 self.
assertAliasesassertAliases(
'B0 -> [^D0 -> pi+ K-] pi0', [
'dzero'], prefix=
'dzero')
73 """Check mother and daughter can be selected for an specific named alias"""
74 self.
assertAliasesassertAliases(
'^B0 -> [^D0 -> pi+ ^K-] pi0', [
'MyB',
'MyD',
'MyK'], prefix=[
'MyB',
'MyD',
'MyK'])
77 """Check daughter can be selected w/o an specific named alias"""
78 self.
assertAliasesassertAliases(
'B0 -> [^D0 -> ^pi+ ^K-] pi0', [
'd0',
'd0_d0',
'd0_d1'], use_names=
False)
81 """Check daughter can be selected w/o an specific named alias"""
82 self.
assertAliasesassertAliases(
'^B0 -> pi0 ^pi0', [
'',
'd1'], use_names=
False)
84 self.
assertAliasesassertAliases(
'^B0 -> pi0 ^pi0', [
'',
'd1'], use_names=
False, use_relative_indices=
True)
87 """Check granddaughter can be selected for an automatic name alias"""
88 self.
assertAliasesassertAliases(
'B0 -> [D0 -> ^pi+ K-] pi0', [
'D0_pi'])
91 """Check multiple granddaughters can be selected for automatic name aliases"""
93 'B0 -> [D0 -> ^pi+ ^pi- ^pi0] ^pi0',
102 """ check decay-string-of-doom with automatic names """
104 "^B0 -> [D0 -> ^pi+ ^pi-] [D+ -> ^pi+ pi0] [D0 -> ^pi+ ^pi-] [K- -> ^pi+ ^pi-] ^pi+ ^pi- pi0",
119 """ check decay-string-of-doom with automatic names and relative indexing"""
121 "^B0 -> [D0 -> ^pi+ ^pi-] [D+ -> ^pi+ pi0] [D0 -> ^pi+ ^pi-] [K- -> ^pi+ ^pi-] ^pi+ ^pi- pi0",
133 ], use_relative_indices=
True)
136 """ check decay-string-of-doom with automatic names and forced indices"""
138 "^B0 -> [D0 -> ^pi+ ^pi-] [D+ -> ^pi+ pi0] [D0 -> ^pi+ ^pi-] [K- -> ^pi+ ^pi-] ^pi+ ^pi- pi0",
150 ], always_include_indices=
True)
153 """ check decay-string-of-doom with automatic names, relative indexing and forced indices"""
155 "^B0 -> [D0 -> ^pi+ ^pi-] [D+ -> ^pi+ pi0] [D0 -> ^pi+ ^pi-] [K- -> ^pi+ ^pi-] ^pi+ ^pi- pi0",
167 ], use_relative_indices=
True, always_include_indices=
True)
170 """ check decay-string-of-doom w/o automatic names """
172 "^B0 -> [D0 -> ^pi+ ^pi-] [D+ -> ^pi+ pi0] [D0 -> ^pi+ ^pi-] [K- -> ^pi+ ^pi-] ^pi+ ^pi- pi0",
187 """ check decay-string-of-doom w/o automatic names and make sure relative indexing is **not** honored"""
189 "^B0 -> [D0 -> ^pi+ ^pi-] [D+ -> ^pi+ pi0] [D0 -> ^pi+ ^pi-] [K- -> ^pi+ ^pi-] ^pi+ ^pi- pi0",
201 ], use_names=
False, use_relative_indices=
True)
204 """ check if the indexing works with more than two ... """
206 "B0 -> [D+ -> [K+ -> ^pi+]] [D+ -> [K+ -> ^pi+]] [D+ -> [K+ -> ^pi+]]",
214 """ check if the indexing works with more than two ... """
216 "B0 -> [D+ -> [K+ -> ^pi+]] [D+ -> [K+ -> ^pi+]] [D+ -> [K+ -> ^pi+]] [D+ -> [K+ -> ^pi+]]",
224 "B0 -> [D+ -> [K+ -> pi+]] [D+ -> [K+ -> ^pi+]] [D+ -> [^K+ -> pi+]] [D+ -> [K+ -> ^pi+]]",
231 "B0 -> [D+ -> [K+ -> pi+]] [D+ -> [K+ -> ^pi+]] [D+ -> [^K+ -> pi+]] [D+ -> [K+ -> ^pi+]]",
236 ], use_relative_indices=
True)
239 """Test many many children"""
241 "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",
253 """Test many many children with relative indices"""
255 "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",
264 ], use_relative_indices=
True)
267 """Test many many children without names"""
268 for use_relative_indices
in True,
False:
269 for always_include_indices
in True,
False:
271 "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",
281 use_relative_indices=use_relative_indices,
282 always_include_indices=always_include_indices,
286 """Select a decay with the inclusive particle marker"""
287 self.
assertAliasesassertAliases(
"B0 -> ^Xsd e+:loose e-:loose", [
"Xsd"])
290 """Print all aliases as a final check"""
294 if __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)