Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: group decay node in decay LaTeX rendering #114

Merged
merged 3 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
12 changes: 6 additions & 6 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)
assert (
latex == R"\Lambda(1520)\left[\frac{3}{2}^-\right] \to"
R" p\left[\frac{1}{2}^+\right] K^-\left[0^-\right]"
)
expected = R"""
\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
Loading