-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
FEAT: implement
all_subsystems
switch in DPD builder (#152)
* DX: activate VS Code coverage extension * DX: add second subsystem to Jpsi to p K Sigma * DX: extract `conftest.py` * DX: increase minimal test coverage to 65% * DX: test `formulate_breit_wigner_with_form_factor()` * FIX: match signature of `formulate_breit_wigner_with_ff()` with `DynamicsBuilder` protocol
Showing
9 changed files
with
186 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# cspell:ignore pksigma | ||
from __future__ import annotations | ||
|
||
from typing import TYPE_CHECKING | ||
|
||
import attrs | ||
import pytest | ||
import qrules | ||
|
||
if TYPE_CHECKING: | ||
from _pytest.fixtures import SubRequest | ||
from qrules.transition import ReactionInfo | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def a2pipipi_reaction() -> ReactionInfo: | ||
return qrules.generate_transitions( | ||
initial_state="a(1)(1260)0", | ||
final_state=["pi0", "pi0", "pi0"], | ||
allowed_intermediate_particles=["a(0)(980)0"], | ||
formalism="helicity", | ||
) | ||
|
||
|
||
@pytest.fixture(scope="session", params=["canonical-helicity", "helicity"]) | ||
def jpsi2pksigma_reaction(request: SubRequest) -> ReactionInfo: | ||
return qrules.generate_transitions( | ||
initial_state=[("J/psi(1S)", [+1])], | ||
final_state=["K0", ("Sigma+", [+0.5]), ("p~", [+0.5])], | ||
allowed_interaction_types="strong", | ||
allowed_intermediate_particles=["N(1700)+", "Sigma(1660)"], | ||
formalism=request.param, | ||
) | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def xib2pkk_reaction() -> ReactionInfo: | ||
reaction = qrules.generate_transitions( | ||
initial_state="Xi(b)-", | ||
final_state=["p", "K-", "K-"], | ||
allowed_intermediate_particles=["Lambda(1520)"], | ||
formalism="helicity", | ||
) | ||
swapped_transitions = tuple( | ||
attrs.evolve(t, topology=t.topology.swap_edges(1, 2)) | ||
for t in reaction.transitions | ||
) | ||
return qrules.transition.ReactionInfo( | ||
transitions=reaction.transitions + swapped_transitions, | ||
formalism=reaction.formalism, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# cspell:ignore pksigma | ||
from __future__ import annotations | ||
|
||
from typing import TYPE_CHECKING | ||
|
||
import pytest | ||
|
||
from ampform_dpd import DalitzPlotDecompositionBuilder | ||
from ampform_dpd.adapter.qrules import normalize_state_ids, to_three_body_decay | ||
from ampform_dpd.dynamics.builder import formulate_breit_wigner_with_form_factor | ||
|
||
if TYPE_CHECKING: | ||
from qrules.transition import ReactionInfo | ||
|
||
|
||
class TestDalitzPlotDecompositionBuilder: | ||
@pytest.mark.parametrize("all_subsystems", [False, True]) | ||
@pytest.mark.parametrize("min_ls", [False, True]) | ||
def test_all_subsystems( | ||
self, jpsi2pksigma_reaction: ReactionInfo, all_subsystems: bool, min_ls: bool | ||
): | ||
if jpsi2pksigma_reaction.formalism == "helicity" and not min_ls: | ||
pytest.skip("Helicity formalism with all LS not supported") | ||
transitions = normalize_state_ids(jpsi2pksigma_reaction.transitions) | ||
decay = to_three_body_decay(transitions, min_ls=min_ls) | ||
builder = DalitzPlotDecompositionBuilder( | ||
decay, min_ls=min_ls, all_subsystems=all_subsystems | ||
) | ||
if jpsi2pksigma_reaction.formalism == "canonical-helicity": | ||
for chain in builder.decay.chains: | ||
builder.dynamics_choices.register_builder( | ||
chain, formulate_breit_wigner_with_form_factor | ||
) | ||
if all_subsystems: | ||
with pytest.warns( | ||
UserWarning, | ||
match=r"Decay J/psi\(1S\) → 1: K0, 2: Sigma\+, 3: p~ only has subsystems 2, 3, not 1", | ||
): | ||
model = builder.formulate(reference_subsystem=2) | ||
else: | ||
model = builder.formulate(reference_subsystem=2) | ||
expected_variables = { | ||
R"\zeta^0_{2(2)}", | ||
R"\zeta^0_{3(2)}", | ||
R"\zeta^2_{2(2)}", | ||
R"\zeta^2_{3(2)}", | ||
R"\zeta^3_{2(2)}", | ||
R"\zeta^3_{3(2)}", | ||
"theta_12", | ||
"theta_23", | ||
"theta_31", | ||
} | ||
if not all_subsystems: | ||
expected_variables.remove("theta_23") | ||
assert {s.name for s in model.variables} == expected_variables |