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

io.aslatex() should not nest arrays blocks with terms_per_line argument #430

Open
redeboer opened this issue Jun 4, 2024 · 0 comments
Open
Assignees
Labels
🐛 Bug Something isn't working

Comments

@redeboer
Copy link
Member

redeboer commented Jun 4, 2024

What happened?

It seems that the new qrules.io.asdot(..., terms_per_line=1) results in nested \begin{array} blocks. This is not required: just use the same array from the top and break with \\ &&.

Relevant log output

qrules.io.aslatex({k: v for i, (k, v) in enumerate(MODEL4BODY.amplitudes.items()) if i < 1}, terms_per_line=1)
\begin{array}{rcl}
  A^{01,23}_{\frac{1}{2}, 0, 0, - \frac{1}{2}, - \frac{1}{2}} &=& \begin{array}{l}
  C_{B^{0} \to J/\psi(1S)_{0} {f_{0}(1370)}_{0}; J/\psi(1S) \to K^{-}_{0} \pi^{+}_{0}; f_{0}(1370) \to \mu^{+}_{+1/2} \mu^{-}_{+1/2}} D^{0}_{0,0}\left(- \phi^{23}_{2},\theta^{23}_{2},0\right) D^{0}_{\frac{1}{2},0}\left(- \phi_{01},\theta_{01},0\right) D^{1}_{0,0}\left(- \phi^{01}_{0},\theta^{01}_{0},0\right) \\
  \; + \; C_{B^{0} \to J/\psi(1S)_{0} {f_{0}(1500)}_{0}; J/\psi(1S) \to K^{-}_{0} \pi^{+}_{0}; f_{0}(1500) \to \mu^{+}_{+1/2} \mu^{-}_{+1/2}} D^{0}_{0,0}\left(- \phi^{23}_{2},\theta^{23}_{2},0\right) D^{0}_{\frac{1}{2},0}\left(- \phi_{01},\theta_{01},0\right) D^{1}_{0,0}\left(- \phi^{01}_{0},\theta^{01}_{0},0\right) \\
  \; + \; C_{B^{0} \to J/\psi(1S)_{0} {f_{0}(1710)}_{0}; J/\psi(1S) \to K^{-}_{0} \pi^{+}_{0}; f_{0}(1710) \to \mu^{+}_{+1/2} \mu^{-}_{+1/2}} D^{0}_{0,0}\left(- \phi^{23}_{2},\theta^{23}_{2},0\right) D^{0}_{\frac{1}{2},0}\left(- \phi_{01},\theta_{01},0\right) D^{1}_{0,0}\left(- \phi^{01}_{0},\theta^{01}_{0},0\right) \\
  \; + \; C_{B^{0} \to J/\psi(1S)_{0} {f_{0}(2020)}_{0}; J/\psi(1S) \to K^{-}_{0} \pi^{+}_{0}; f_{0}(2020) \to \mu^{+}_{+1/2} \mu^{-}_{+1/2}} D^{0}_{0,0}\left(- \phi^{23}_{2},\theta^{23}_{2},0\right) D^{0}_{\frac{1}{2},0}\left(- \phi_{01},\theta_{01},0\right) D^{1}_{0,0}\left(- \phi^{01}_{0},\theta^{01}_{0},0\right) \\
  \; + \; C_{B^{0} \to J/\psi(1S)_{0} {f_{0}(500)}_{0}; J/\psi(1S) \to K^{-}_{0} \pi^{+}_{0}; f_{0}(500) \to \mu^{+}_{+1/2} \mu^{-}_{+1/2}} D^{0}_{0,0}\left(- \phi^{23}_{2},\theta^{23}_{2},0\right) D^{0}_{\frac{1}{2},0}\left(- \phi_{01},\theta_{01},0\right) D^{1}_{0,0}\left(- \phi^{01}_{0},\theta^{01}_{0},0\right) \\
  \; + \; C_{B^{0} \to J/\psi(1S)_{0} {f_{0}(980)}_{0}; J/\psi(1S) \to K^{-}_{0} \pi^{+}_{0}; f_{0}(980) \to \mu^{+}_{+1/2} \mu^{-}_{+1/2}} D^{0}_{0,0}\left(- \phi^{23}_{2},\theta^{23}_{2},0\right) D^{0}_{\frac{1}{2},0}\left(- \phi_{01},\theta_{01},0\right) D^{1}_{0,0}\left(- \phi^{01}_{0},\theta^{01}_{0},0\right) \\
\end{array} \\
\end{array}

image

Is it possible to reproduce the bug with a small code snippet?

While investigating B0 -> (J/psi->mu+mu-) pi K:

from qrules.transition import StateTransitionManager

stm = StateTransitionManager(
    initial_state=[("B0", [+0.5])],
    final_state=["K-", "pi+", "mu+", "mu-"],
    formalism="helicity",
)
stm.add_final_state_grouping([["K-", "pi+"], ["mu+", "mu-"]])
stm.set_allowed_intermediate_particles(r"^(J/psi\(1S\)|f\(0\).*)$", regex=True)
problem_sets = stm.create_problem_sets()
reaction_full = stm.find_solutions(problem_sets)


```python
import qrules

reaction= qrules.ReactionInfo(
    transitions=tuple(
        transition
        for transition in reaction_full.transitions
        if transition.states[4].particle.name == "J/psi(1S)"
    ),
    formalism=reaction4body_full.formalism,
)
import ampform

builder = ampform.get_builder(REACTION4BODY)
builder.adapter.permutate_registered_topologies()
builder.config.scalar_initial_state_mass = True
builder.config.stable_final_state_ids = reaction.final_state
model = builder.formulate()
model.intensity.cleanup()


### Additional steps to reproduce the bug

_No response_

### Which Python version were you using?

Python 3.12

### Python dependencies

```plain text
absl-py==2.1.0
ampform==0.15.4
ampform-dpd==0.2.0
anyio==4.4.0
argon2-cffi==23.1.0
argon2-cffi-bindings==21.2.0
arrow==1.3.0
asttokens==2.4.1
astunparse==1.6.3
async-lru==2.0.4
attrs==23.2.0
Babel==2.15.0
beautifulsoup4==4.12.3
bleach==6.1.0
cattrs==23.2.3
certifi==2024.6.2
cffi==1.16.0
cfgv==3.4.0
charset-normalizer==3.3.2
cloudpickle==3.0.0
colorama==0.4.6
comm==0.2.2
contourpy==1.2.1
cycler==0.12.1
debugpy==1.8.1
decorator==5.1.1
defusedxml==0.7.1
distlib==0.3.8
dm-tree==0.1.8
docstring-to-markdown==0.15
executing==2.0.1
fastjsonschema==2.19.1
filelock==3.14.0
flatbuffers==24.3.25
fonttools==4.53.0
fqdn==1.5.1
gast==0.5.4
gitdb==4.0.11
GitPython==3.1.43
google-pasta==0.2.0
graphviz==0.20.3
grpcio==1.64.0
h11==0.14.0
h5py==3.11.0
hepunits==2.3.3
httpcore==1.0.5
httpx==0.27.0
identify==2.5.36
idna==3.7
iminuit==2.26.0
ipykernel==6.29.4
ipython==8.25.0
ipywidgets==8.1.3
isoduration==20.11.0
isort==5.13.2
jax==0.4.28
jaxlib==0.4.28
jedi==0.19.1
Jinja2==3.1.4
json5==0.9.25
jsonpointer==2.4
jsonschema==4.22.0
jsonschema-specifications==2023.12.1
jupyter-events==0.10.0
jupyter-lsp==2.2.5
jupyter-server-mathjax==0.2.6
jupyter_client==8.6.2
jupyter_core==5.7.2
jupyter_server==2.14.1
jupyter_server_terminals==0.5.3
jupyterlab==4.2.1
jupyterlab-lsp==5.1.0
jupyterlab_code_formatter==2.2.1
jupyterlab_git==0.50.1
jupyterlab_pygments==0.3.0
jupyterlab_server==2.27.2
jupyterlab_widgets==3.0.11
keras==3.3.3
kiwisolver==1.4.5
libclang==18.1.1
lsprotocol==2023.0.1
Markdown==3.6
markdown-it-py==3.0.0
MarkupSafe==2.1.5
matplotlib==3.9.0
matplotlib-inline==0.1.7
mdurl==0.1.2
mistune==3.0.2
ml-dtypes==0.3.2
mpmath==1.3.0
namex==0.0.8
nbclient==0.10.0
nbconvert==7.16.4
nbdime==4.0.1
nbformat==5.10.4
nest-asyncio==1.6.0
nodeenv==1.9.0
notebook_shim==0.2.4
numpy==1.26.4
opt-einsum==3.3.0
optree==0.11.0
overrides==7.7.0
packaging==24.0
pandas==2.2.2
pandocfilters==1.5.1
parso==0.8.4
particle==0.24.0
pexpect==4.9.0
phasespace==1.10.3
pillow==10.3.0
platformdirs==4.2.2
pluggy==1.5.0
pre-commit==3.7.1
prometheus_client==0.20.0
prompt_toolkit==3.0.45
protobuf==4.25.3
psutil==5.9.8
ptyprocess==0.7.0
pure-eval==0.2.2
pycparser==2.22
Pygments==2.18.0
pyparsing==3.1.2
python-constraint2==2.0.0b5
python-dateutil==2.9.0.post0
python-json-logger==2.0.7
python-lsp-jsonrpc==1.1.2
python-lsp-ruff==2.2.1
python-lsp-server==1.11.0
pytz==2024.1
PyYAML==6.0.1
pyzmq==26.0.3
qrules==0.10.2
referencing==0.35.1
requests==2.32.3
rfc3339-validator==0.1.4
rfc3986-validator==0.1.1
rich==13.7.1
rpds-py==0.18.1
ruff==0.4.7
scipy==1.13.1
Send2Trash==1.8.3
setuptools==69.5.1
six==1.16.0
smmap==5.0.1
sniffio==1.3.1
soupsieve==2.5
stack-data==0.6.3
sympy==1.12.1
tensorboard==2.16.2
tensorboard-data-server==0.7.2
tensorflow==2.16.1
tensorflow-probability==0.24.0
tensorwaves==0.4.12
termcolor==2.4.0
terminado==0.18.1
tinycss2==1.3.0
tornado==6.4
tqdm==4.66.4
traitlets==5.14.3
types-python-dateutil==2.9.0.20240316
typing_extensions==4.12.1
tzdata==2024.1
ujson==5.10.0
uri-template==1.3.0
urllib3==2.2.1
uv==0.2.5
virtualenv==20.26.2
wcwidth==0.2.13
webcolors==1.13
webencodings==0.5.1
websocket-client==1.8.0
Werkzeug==3.0.3
wheel==0.43.0
widgetsnbextension==4.0.11
wrapt==1.16.0
@redeboer redeboer added the 🐛 Bug Something isn't working label Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants