From 16904e11c92692213f347d35642ea3377443147b Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Mon, 29 Apr 2024 09:33:38 +0200 Subject: [PATCH 1/2] MAINT: switch to multiline string in test --- tests/test_io.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/test_io.py b/tests/test_io.py index b5a883ba..0ff7cbaf 100644 --- a/tests/test_io.py +++ b/tests/test_io.py @@ -42,10 +42,10 @@ def test_aslatex_isobar_node(): latex = aslatex(node) assert latex == R"\Lambda(1520) \to p K^-" 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""" + \Lambda(1520)\left[\frac{3}{2}^-\right] \to p\left[\frac{1}{2}^+\right] K^-\left[0^-\right] + """.strip() + assert latex == expected node = IsobarNode(Λ1520, p, K, interaction=(2, 1)) latex = aslatex(node) From 3f7b028eeaf8e0849418f9f357ed7d0b2772fa19 Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Sat, 27 Apr 2024 22:05:48 +0200 Subject: [PATCH 2/2] ENH: group decay node in decay LaTeX rendering --- src/ampform_dpd/io.py | 5 ++++- tests/test_io.py | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) 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 0ff7cbaf..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) 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(