Skip to content

Commit

Permalink
ENH: group decay node in decay LaTeX rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
redeboer committed Apr 29, 2024
1 parent 16904e1 commit 3f7b028
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 4 additions & 1 deletion src/ampform_dpd/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,10 @@ def render_arrow(node: IsobarNode) -> str:
to = render_arrow(obj)
child1 = aslatex(obj.child1, **kwargs)
child2 = aslatex(obj.child2, **kwargs)
return Rf"{parent} {to} {child1} {child2}"
latex = Rf"{parent} {to} {child1} {child2}"
if isinstance(obj.parent, State):
return latex
return Rf"\left({latex}\right)"


@aslatex.register(ThreeBodyDecay)
Expand Down
6 changes: 3 additions & 3 deletions tests/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,16 @@ def test_aslatex_particle():
def test_aslatex_isobar_node():
node = IsobarNode(Λ1520, p, K)
latex = aslatex(node)
assert latex == R"\Lambda(1520) \to p K^-"
assert latex == R"\left(\Lambda(1520) \to p K^-\right)"
latex = aslatex(node, with_jp=True)
expected = R"""
\Lambda(1520)\left[\frac{3}{2}^-\right] \to p\left[\frac{1}{2}^+\right] K^-\left[0^-\right]
\left(\Lambda(1520)\left[\frac{3}{2}^-\right] \to p\left[\frac{1}{2}^+\right] K^-\left[0^-\right]\right)
""".strip()
assert latex == expected

node = IsobarNode(Λ1520, p, K, interaction=(2, 1))
latex = aslatex(node)
assert latex == R"\Lambda(1520) \xrightarrow[S=1]{L=2} p K^-"
assert latex == R"\left(\Lambda(1520) \xrightarrow[S=1]{L=2} p K^-\right)"


@pytest.mark.parametrize(
Expand Down

0 comments on commit 3f7b028

Please sign in to comment.