Skip to content

Commit

Permalink
FIX: handle None parity in parity_conservation (#211)
Browse files Browse the repository at this point in the history
* DOC: add `IPython` to intersphinx inventory

* DX: update "🐛 Bug" label in allowed PR labels

* MAINT: remove `Sigma` from Lc to pKpi test
  Suppressed by diquark dynamics (isospin)
  • Loading branch information
redeboer authored Apr 3, 2023
1 parent c21351e commit 8a20136
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/pr-linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ jobs:
steps:
- uses: docker://agilepathway/pull-request-label-checker:latest
with:
any_of: Bug,✨ Feature,⚠️ Interface,📝 Docs,🔨 Maintenance,🖱️ DX
any_of: >-
🐛 Bug,✨ Feature,⚠️ Interface,📝 Docs,🔨 Maintenance,🖱️ DX
none_of: Epic,❌ Won't fix,💫 Good first issue
repo_token: ${{ secrets.GITHUB_TOKEN }}

Expand Down
1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ def get_version(package_name: str) -> str:
"compwa-org": ("https://compwa-org.readthedocs.io", None),
"constraint": ("https://labix.org/doc/constraint/public", "constraint.inv"),
"graphviz": ("https://graphviz.readthedocs.io/en/stable", None),
"IPython": (f"https://ipython.readthedocs.io/en/{get_version('IPython')}", None),
"jsonschema": ("https://python-jsonschema.readthedocs.io/en/stable", None),
"mypy": ("https://mypy.readthedocs.io/en/stable", None),
"pwa": ("https://pwa.readthedocs.io", None),
Expand Down
2 changes: 2 additions & 0 deletions src/qrules/conservation_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ def parity_conservation(
l_magnitude: NodeQN.l_magnitude,
) -> bool:
r"""Implement :math:`P_{in} = P_{out} \cdot (-1)^L`."""
if any(p is None for p in [*ingoing_edge_qns, *outgoing_edge_qns]):
return False
if len(ingoing_edge_qns) == 1 and len(outgoing_edge_qns) == 2:
parity_in = reduce(lambda x, y: x * y.value, ingoing_edge_qns, 1)
parity_out = reduce(lambda x, y: x * y.value, outgoing_edge_qns, 1)
Expand Down
3 changes: 1 addition & 2 deletions tests/channels/test_lc_to_p_km_pip.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ def test_resonances():
stm = StateTransitionManager(
initial_state=["Lambda(c)+"],
final_state=["p", "K-", "pi+"],
allowed_intermediate_particles=["Delta", "K", "Lambda"],
mass_conservation_factor=0,
)
stm.set_allowed_interaction_types([InteractionType.STRONG], node_id=1)
Expand All @@ -23,6 +24,4 @@ def test_resonances():
"Lambda(1810)",
"Lambda(1800)",
"Lambda(1890)",
"Sigma(1660)0",
"Sigma(1750)0",
]
20 changes: 20 additions & 0 deletions tests/channels/test_y_to_d0_d0bar_pi0_pi0.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,23 @@ def test_full(formalism, n_solutions, particle_database):
reaction = stm.find_solutions(problem_sets)
assert len(reaction.group_by_topology()) == 1
assert len(reaction.transitions) == n_solutions


def test_resonance_filter(particle_database):
# https://github.com/ComPWA/qrules/issues/33
stm = StateTransitionManager(
initial_state=[("Y(4260)", [-1, +1])],
final_state=["D0", "D~0", "pi0", "pi0"],
allowed_intermediate_particles=["D"],
particle_db=particle_database,
)
stm.set_allowed_interaction_types([InteractionType.STRONG])
stm.add_final_state_grouping([["D0", "pi0"], ["D~0", "pi0"]])
problem_sets = stm.create_problem_sets()
result = stm.find_solutions(problem_sets)
assert set(result.get_intermediate_particles().names) == {
"D*(2007)0",
"D*(2007)~0",
"D(0)*(2300)0",
"D(0)*(2300)~0",
}

0 comments on commit 8a20136

Please sign in to comment.