-
Notifications
You must be signed in to change notification settings - Fork 14
/
test_utilities.py
45 lines (39 loc) · 1.43 KB
/
test_utilities.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# Copyright (c) 2018-2024, Eduardo Rodrigues and Henry Schreiner.
#
# Distributed under the 3-clause BSD license, see accompanying file LICENSE
# or https://github.com/scikit-hep/decaylanguage for details.
from __future__ import annotations
import pytest
from decaylanguage import DecayChain, DecayMode
from decaylanguage.utils import DescriptorFormat
dm1 = DecayMode(0.6770, "D0 pi+") # D*+
dm2 = DecayMode(0.0124, "K_S0 pi0") # D0
dm3 = DecayMode(0.692, "pi+ pi-") # K_S0
dm4 = DecayMode(0.98823, "gamma gamma") # pi0
@pytest.mark.parametrize(
("decay_pattern", "sub_decay_pattern", "expected"),
[
(
"{mother} -> {daughters}",
"({mother} -> {daughters})",
"D*+ -> (D0 -> (K_S0 -> pi+ pi-) (pi0 -> gamma gamma)) pi+",
),
(
"{mother} --> {daughters}",
"[{mother} --> {daughters}]",
"D*+ --> [D0 --> [K_S0 --> pi+ pi-] [pi0 --> gamma gamma]] pi+",
),
(
"{mother} => {daughters}",
"{mother} (=> {daughters})",
"D*+ => D0 (=> K_S0 (=> pi+ pi-) pi0 (=> gamma gamma)) pi+",
),
],
)
def test_set_descriptor_pattern(
decay_pattern: str, sub_decay_pattern: str, expected: str
):
dc = DecayChain("D*+", {"D*+": dm1, "D0": dm2, "K_S0": dm3, "pi0": dm4})
with DescriptorFormat(decay_pattern, sub_decay_pattern):
descriptor = dc.to_string()
assert descriptor == expected