diff --git a/src/ampform_dpd/io.py b/src/ampform_dpd/io.py index 65149f3c..b87252d9 100644 --- a/src/ampform_dpd/io.py +++ b/src/ampform_dpd/io.py @@ -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) diff --git a/tests/test_io.py b/tests/test_io.py index b5a883ba..ea4081af 100644 --- a/tests/test_io.py +++ b/tests/test_io.py @@ -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(