Skip to content

Commit b351735

Browse files
authored
BEHAVIOR: return mass with index for State (#172)
* MAINT: update test hashes
1 parent 8ca6761 commit b351735

3 files changed

Lines changed: 31 additions & 28 deletions

File tree

src/ampform_dpd/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
get_decay_product_ids,
3232
to_particle,
3333
)
34+
from ampform_dpd.dynamics.builder import create_mass_symbol
3435
from ampform_dpd.spin import create_spin_range
3536

3637
if TYPE_CHECKING:
@@ -485,7 +486,7 @@ def formulate_non_resonant(
485486

486487
def create_mass_symbol_mapping(decay: ThreeBodyDecay) -> dict[sp.Symbol, float]:
487488
return {
488-
sp.Symbol(f"m{i}", nonnegative=True): decay.states[i].mass
489+
create_mass_symbol(decay.states[i]): decay.states[i].mass
489490
for i in sorted(decay.states) # ensure that dict keys are sorted by state ID
490491
}
491492

src/ampform_dpd/dynamics/builder.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,10 @@ def _create_meson_radius_symbol(isobar: IsobarNode) -> sp.Symbol:
107107
return sp.Symbol(R"R_\mathrm{res}", nonnegative=True)
108108

109109

110-
def create_mass_symbol(particle: IsobarNode | Particle) -> sp.Symbol:
110+
def create_mass_symbol(particle: IsobarNode | Particle | State) -> sp.Symbol:
111111
particle = to_particle(particle)
112+
if isinstance(particle, State):
113+
return sp.Symbol(f"m{particle.index}", nonnegative=True)
112114
return sp.Symbol(f"m_{{{particle.latex}}}", nonnegative=True)
113115

114116

tests/test_cached.py

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
@pytest.mark.parametrize(
1919
("min_ls", "expected_hashes"),
2020
[
21-
pytest.param(True, {"ba9b5fd"}, id="min-ls"),
22-
pytest.param(False, {"8039460"}, id="all-ls"),
21+
pytest.param(True, {"544cb15"}, id="min-ls"),
22+
pytest.param(False, {"01968bc", "7300a10"}, id="all-ls"),
2323
],
2424
)
2525
def test_hashes(reaction: ReactionInfo, min_ls: bool, expected_hashes: set[str]):
@@ -51,30 +51,30 @@ def test_amplitude_doit_hashes(reaction: ReactionInfo):
5151
}
5252
print(hashes)
5353
assert hashes == {
54-
"A2[-1,0,-1/2,-1/2]": "6770935",
55-
"A3[-1,0,-1/2,-1/2]": "5b5001a",
56-
"A2[-1,0,-1/2,1/2]": "716e629",
57-
"A3[-1,0,-1/2,1/2]": "d338945",
58-
"A2[-1,0,1/2,-1/2]": "78bf694",
59-
"A3[-1,0,1/2,-1/2]": "b72a7e2",
60-
"A2[-1,0,1/2,1/2]": "b1e428d",
61-
"A3[-1,0,1/2,1/2]": "8730459",
62-
"A2[0,0,-1/2,-1/2]": "c9cb5e9",
63-
"A3[0,0,-1/2,-1/2]": "a62c07e",
64-
"A2[0,0,-1/2,1/2]": "b87152c",
65-
"A3[0,0,-1/2,1/2]": "8961c3b",
66-
"A2[0,0,1/2,-1/2]": "73f76f4",
67-
"A3[0,0,1/2,-1/2]": "82d805d",
68-
"A2[0,0,1/2,1/2]": "36dd5d0",
69-
"A3[0,0,1/2,1/2]": "ac73d2d",
70-
"A2[1,0,-1/2,-1/2]": "7f8513f",
71-
"A3[1,0,-1/2,-1/2]": "3691bba",
72-
"A2[1,0,-1/2,1/2]": "165a2ad",
73-
"A3[1,0,-1/2,1/2]": "7c7b3cf",
74-
"A2[1,0,1/2,-1/2]": "e3ff1a7",
75-
"A3[1,0,1/2,-1/2]": "06027b1",
76-
"A2[1,0,1/2,1/2]": "eb57212",
77-
"A3[1,0,1/2,1/2]": "3ef2476",
54+
"A2[-1,0,-1/2,-1/2]": "652522d",
55+
"A3[-1,0,-1/2,-1/2]": "5d8b698",
56+
"A2[-1,0,-1/2,1/2]": "0a944fe",
57+
"A3[-1,0,-1/2,1/2]": "a564151",
58+
"A2[-1,0,1/2,-1/2]": "4732f96",
59+
"A3[-1,0,1/2,-1/2]": "67bc82d",
60+
"A2[-1,0,1/2,1/2]": "98370c7",
61+
"A3[-1,0,1/2,1/2]": "00d5d44",
62+
"A2[0,0,-1/2,-1/2]": "aef2ca4",
63+
"A3[0,0,-1/2,-1/2]": "bcb25df",
64+
"A2[0,0,-1/2,1/2]": "00c9500",
65+
"A3[0,0,-1/2,1/2]": "7f73b98",
66+
"A2[0,0,1/2,-1/2]": "f3ade16",
67+
"A3[0,0,1/2,-1/2]": "96ec036",
68+
"A2[0,0,1/2,1/2]": "81dcaa6",
69+
"A3[0,0,1/2,1/2]": "6a547e5",
70+
"A2[1,0,-1/2,-1/2]": "09ca576",
71+
"A3[1,0,-1/2,-1/2]": "b3ed335",
72+
"A2[1,0,-1/2,1/2]": "beed520",
73+
"A3[1,0,-1/2,1/2]": "115597f",
74+
"A2[1,0,1/2,-1/2]": "f6e2775",
75+
"A3[1,0,1/2,-1/2]": "0d898ee",
76+
"A2[1,0,1/2,1/2]": "9276158",
77+
"A3[1,0,1/2,1/2]": "f3fc8c5",
7878
}
7979

8080

0 commit comments

Comments
 (0)