|
1 | 1 | # pyright: reportPrivateUsage=false |
2 | 2 | from __future__ import annotations |
3 | 3 |
|
4 | | -from ampform_dpd.decay import IsobarNode, Particle |
5 | | -from ampform_dpd.io import aslatex |
| 4 | +from textwrap import dedent |
| 5 | + |
| 6 | +from attrs import asdict |
| 7 | + |
| 8 | +from ampform_dpd.decay import IsobarNode, Particle, State |
| 9 | +from ampform_dpd.io import as_markdown_table, aslatex |
6 | 10 |
|
7 | 11 | # https://compwa-org--129.org.readthedocs.build/report/018.html#resonances-and-ls-scheme |
8 | 12 | dummy_args = {"mass": 0, "width": 0} |
@@ -35,3 +39,18 @@ def test_aslatex_isobar_node(): |
35 | 39 | node = IsobarNode(Λ1520, p, K, interaction=(2, 1)) |
36 | 40 | latex = aslatex(node) |
37 | 41 | assert latex == R"\left(\Lambda(1520) \xrightarrow[S=1]{L=2} p K^-\right)" |
| 42 | + |
| 43 | + |
| 44 | +def test_as_markdown_table_particles(): |
| 45 | + p_state = State(**asdict(p), index=1) |
| 46 | + k_state = State(**asdict(K), index=2) |
| 47 | + particles = [p_state, k_state, π] |
| 48 | + src = as_markdown_table(particles) |
| 49 | + expected = dedent(R""" |
| 50 | + | index | name | LaTeX | $J^P$ | mass (MeV) | width (MeV) | |
| 51 | + | --- | --- | --- | --- | --- | --- | |
| 52 | + | 1 | `p` | $p$ | $\frac{1}{2}^+$ | 0 | 0 | |
| 53 | + | 2 | `K-` | $K^-$ | $0^-$ | 0 | 0 | |
| 54 | + | | `π+` | $\pi^+$ | $0^-$ | 0 | 0 | |
| 55 | + """) |
| 56 | + assert src.strip() == expected.strip() |
0 commit comments