From 56e191a16f21c11e8e5dced6986c6a9de498ab5f Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Wed, 8 Nov 2023 23:03:37 +0100 Subject: [PATCH] MAINT: update pip constraints and pre-commit (#363) * MAINT: apply new `black` formatting --------- Co-authored-by: GitHub Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .constraints/py3.10.txt | 96 +++++------ .constraints/py3.11.txt | 96 +++++------ .constraints/py3.7.txt | 30 ++-- .constraints/py3.8.txt | 88 +++++----- .constraints/py3.9.txt | 98 ++++++----- .pre-commit-config.yaml | 16 +- docs/_extend_docstrings.py | 1 + docs/_relink_references.py | 1 + docs/conf.py | 59 +++---- docs/usage/dynamics/k-matrix.ipynb | 82 ++++----- docs/usage/interactive.ipynb | 22 ++- docs/usage/kinematics.ipynb | 12 +- src/ampform/dynamics/__init__.py | 27 +-- src/ampform/dynamics/builder.py | 1 + src/ampform/dynamics/kmatrix.py | 219 +++++++++++------------- src/ampform/dynamics/phasespace.py | 5 +- src/ampform/helicity/__init__.py | 27 ++- src/ampform/helicity/align/__init__.py | 1 + src/ampform/helicity/align/axisangle.py | 1 + src/ampform/helicity/align/dpd.py | 17 +- src/ampform/helicity/decay.py | 1 + src/ampform/helicity/naming.py | 1 + src/ampform/io/__init__.py | 1 + src/ampform/kinematics/__init__.py | 3 +- src/ampform/kinematics/angles.py | 43 ++--- src/ampform/kinematics/lorentz.py | 99 +++++------ src/ampform/kinematics/phasespace.py | 1 + src/ampform/sympy/__init__.py | 11 +- src/ampform/sympy/_array_expressions.py | 1 + src/ampform/sympy/math.py | 1 + src/symplot/__init__.py | 13 +- tests/conftest.py | 104 ++++++----- tests/helicity/test_helicity.py | 10 +- tests/kinematics/test_angles.py | 181 +++++++++----------- tests/kinematics/test_lorentz.py | 28 ++- tests/symplot/test_ipywidgets.py | 1 + 36 files changed, 643 insertions(+), 755 deletions(-) diff --git a/.constraints/py3.10.txt b/.constraints/py3.10.txt index 5a81dbfc9..ac888e030 100644 --- a/.constraints/py3.10.txt +++ b/.constraints/py3.10.txt @@ -10,24 +10,23 @@ anyio==4.0.0 argon2-cffi==23.1.0 argon2-cffi-bindings==21.2.0 arrow==1.3.0 -asttokens==2.4.0 +asttokens==2.4.1 async-lru==2.0.4 attrs==23.1.0 -babel==2.13.0 -backcall==0.2.0 +babel==2.13.1 beautifulsoup4==4.12.2 -black==23.9.1 +black==23.11.0 bleach==6.1.0 -cachetools==5.3.1 +cachetools==5.3.2 certifi==2023.7.22 cffi==1.16.0 cfgv==3.4.0 chardet==5.2.0 -charset-normalizer==3.3.0 +charset-normalizer==3.3.2 click==8.1.7 colorama==0.4.6 -comm==0.1.4 -contourpy==1.1.1 +comm==0.2.0 +contourpy==1.2.0 coverage==7.3.2 cycler==0.12.1 debugpy==1.8.0 @@ -35,27 +34,27 @@ decorator==5.1.1 defusedxml==0.7.1 deprecated==1.2.14 distlib==0.3.7 -docstring-to-markdown==0.12 +docstring-to-markdown==0.13 docutils==0.17.1 exceptiongroup==1.1.3 execnet==2.0.2 -executing==2.0.0 +executing==2.0.1 fastjsonschema==2.18.1 -filelock==3.12.4 -fonttools==4.43.1 +filelock==3.13.1 +fonttools==4.44.0 fqdn==1.5.1 gprof2dot==2022.7.29 graphviz==0.20.1 -greenlet==3.0.0 +greenlet==3.0.1 hepunits==2.3.2 -identify==2.5.30 +identify==2.5.31 idna==3.4 imagesize==1.4.1 importlib-metadata==6.8.0 iniconfig==2.0.0 -ipykernel==6.25.2 +ipykernel==6.26.0 ipympl==0.9.3 -ipython==8.16.1 +ipython==8.17.2 ipython-genutils==0.2.0 ipywidgets==8.1.1 isoduration==20.11.0 @@ -63,46 +62,46 @@ jedi==0.19.1 jinja2==3.1.2 json5==0.9.14 jsonpointer==2.4 -jsonschema==4.19.1 +jsonschema==4.19.2 jsonschema-specifications==2023.7.1 jupyter-cache==0.6.1 -jupyter-client==8.3.1 -jupyter-core==5.3.2 -jupyter-events==0.7.0 +jupyter-client==8.6.0 +jupyter-core==5.5.0 +jupyter-events==0.9.0 jupyter-lsp==2.2.0 -jupyter-server==2.7.3 +jupyter-server==2.10.0 jupyter-server-terminals==0.4.4 -jupyterlab==4.0.6 +jupyterlab==4.0.8 jupyterlab-code-formatter==2.2.1 jupyterlab-lsp==5.0.0 -jupyterlab-myst==2.0.2 +jupyterlab-myst==2.1.0 jupyterlab-pygments==0.2.2 -jupyterlab-server==2.25.0 +jupyterlab-server==2.25.1 jupyterlab-widgets==3.0.9 kiwisolver==1.4.5 latexcodec==2.0.1 livereload==2.6.3 markdown-it-py==2.2.0 markupsafe==2.1.3 -matplotlib==3.8.0 +matplotlib==3.8.1 matplotlib-inline==0.1.6 mdit-py-plugins==0.3.5 mdurl==0.1.2 mistune==3.0.2 mpl-interactions==0.23.2 mpmath==1.3.0 -mypy==1.5.1 +mypy==1.6.1 mypy-extensions==1.0.0 myst-nb==0.17.2 myst-parser==0.18.1 nbclient==0.6.8 -nbconvert==7.9.2 +nbconvert==7.11.0 nbformat==5.9.2 -nbmake==1.4.5 +nbmake==1.4.6 nest-asyncio==1.5.8 nodeenv==1.8.0 notebook-shim==0.2.3 -numpy==1.26.0 +numpy==1.26.1 overrides==7.4.0 packaging==23.2 pandocfilters==1.5.0 @@ -110,24 +109,23 @@ parso==0.8.3 particle==0.23.0 pathspec==0.11.2 pexpect==4.8.0 -pickleshare==0.7.5 -pillow==10.0.1 +pillow==10.1.0 platformdirs==3.11.0 pluggy==1.3.0 -pre-commit==3.4.0 -prometheus-client==0.17.1 +pre-commit==3.5.0 +prometheus-client==0.18.0 prompt-toolkit==3.0.39 -psutil==5.9.5 +psutil==5.9.6 ptyprocess==0.7.0 pure-eval==0.2.2 pybtex==0.24.0 pybtex-docutils==1.0.3 pycparser==2.21 -pydata-sphinx-theme==0.14.1 +pydata-sphinx-theme==0.14.3 pygments==2.16.1 pyparsing==3.1.1 pyproject-api==1.6.1 -pytest==7.4.2 +pytest==7.4.3 pytest-cov==4.1.0 pytest-profiling==1.7.0 pytest-xdist==3.3.1 @@ -135,8 +133,8 @@ python-constraint==1.4.0 python-dateutil==2.8.2 python-json-logger==2.0.7 python-lsp-jsonrpc==1.1.2 -python-lsp-server==1.8.2 -pytoolconfig==1.2.5 +python-lsp-server==1.9.0 +pytoolconfig==1.2.6 pyyaml==6.0.1 pyzmq==25.1.1 qrules==0.9.8 @@ -145,9 +143,9 @@ requests==2.31.0 rfc3339-validator==0.1.4 rfc3986-validator==0.1.1 rich==13.6.0 -rope==1.10.0 -rpds-py==0.10.4 -ruff==0.0.292 +rope==1.11.0 +rpds-py==0.12.0 +ruff==0.1.4 send2trash==1.8.2 six==1.16.0 sniffio==1.3.0 @@ -161,7 +159,7 @@ sphinx-comments==0.0.3 sphinx-copybutton==0.5.2 sphinx-design==0.5.0 sphinx-hep-pdgref==0.2.0 -sphinx-thebe==0.2.1 +sphinx-thebe==0.3.0 sphinx-togglebutton==0.3.2 sphinxcontrib-applehelp==1.0.7 sphinxcontrib-bibtex==2.6.1 @@ -170,7 +168,7 @@ sphinxcontrib-htmlhelp==2.0.4 sphinxcontrib-jsmath==1.0.1 sphinxcontrib-qthelp==1.0.6 sphinxcontrib-serializinghtml==1.1.9 -sqlalchemy==2.0.21 +sqlalchemy==2.0.23 stack-data==0.6.3 sympy==1.12 tabulate==0.9.0 @@ -180,22 +178,22 @@ tomli==2.0.1 tornado==6.3.3 tox==4.11.3 tqdm==4.66.1 -traitlets==5.11.2 +traitlets==5.13.0 types-docutils==0.20.0.3 types-pkg-resources==0.1.3 types-python-dateutil==2.8.19.14 -types-requests==2.31.0.8 +types-requests==2.31.0.10 types-setuptools==68.2.0.0 typing-extensions==4.8.0 ujson==5.8.0 uri-template==1.3.0 -urllib3==2.0.6 -virtualenv==20.24.5 -wcwidth==0.2.8 +urllib3==2.0.7 +virtualenv==20.24.6 +wcwidth==0.2.9 webcolors==1.13 webencodings==0.5.1 websocket-client==1.6.4 -wheel==0.41.2 +wheel==0.41.3 widgetsnbextension==4.0.9 wrapt==1.15.0 zipp==3.17.0 diff --git a/.constraints/py3.11.txt b/.constraints/py3.11.txt index 1bda2591a..e8bf01057 100644 --- a/.constraints/py3.11.txt +++ b/.constraints/py3.11.txt @@ -10,24 +10,23 @@ anyio==4.0.0 argon2-cffi==23.1.0 argon2-cffi-bindings==21.2.0 arrow==1.3.0 -asttokens==2.4.0 +asttokens==2.4.1 async-lru==2.0.4 attrs==23.1.0 -babel==2.13.0 -backcall==0.2.0 +babel==2.13.1 beautifulsoup4==4.12.2 -black==23.9.1 +black==23.11.0 bleach==6.1.0 -cachetools==5.3.1 +cachetools==5.3.2 certifi==2023.7.22 cffi==1.16.0 cfgv==3.4.0 chardet==5.2.0 -charset-normalizer==3.3.0 +charset-normalizer==3.3.2 click==8.1.7 colorama==0.4.6 -comm==0.1.4 -contourpy==1.1.1 +comm==0.2.0 +contourpy==1.2.0 coverage==7.3.2 cycler==0.12.1 debugpy==1.8.0 @@ -35,26 +34,26 @@ decorator==5.1.1 defusedxml==0.7.1 deprecated==1.2.14 distlib==0.3.7 -docstring-to-markdown==0.12 +docstring-to-markdown==0.13 docutils==0.17.1 execnet==2.0.2 -executing==2.0.0 +executing==2.0.1 fastjsonschema==2.18.1 -filelock==3.12.4 -fonttools==4.43.1 +filelock==3.13.1 +fonttools==4.44.0 fqdn==1.5.1 gprof2dot==2022.7.29 graphviz==0.20.1 -greenlet==3.0.0 +greenlet==3.0.1 hepunits==2.3.2 -identify==2.5.30 +identify==2.5.31 idna==3.4 imagesize==1.4.1 importlib-metadata==6.8.0 iniconfig==2.0.0 -ipykernel==6.25.2 +ipykernel==6.26.0 ipympl==0.9.3 -ipython==8.16.1 +ipython==8.17.2 ipython-genutils==0.2.0 ipywidgets==8.1.1 isoduration==20.11.0 @@ -62,46 +61,46 @@ jedi==0.19.1 jinja2==3.1.2 json5==0.9.14 jsonpointer==2.4 -jsonschema==4.19.1 +jsonschema==4.19.2 jsonschema-specifications==2023.7.1 jupyter-cache==0.6.1 -jupyter-client==8.3.1 -jupyter-core==5.3.2 -jupyter-events==0.7.0 +jupyter-client==8.6.0 +jupyter-core==5.5.0 +jupyter-events==0.9.0 jupyter-lsp==2.2.0 -jupyter-server==2.7.3 +jupyter-server==2.10.0 jupyter-server-terminals==0.4.4 -jupyterlab==4.0.6 +jupyterlab==4.0.8 jupyterlab-code-formatter==2.2.1 jupyterlab-lsp==5.0.0 -jupyterlab-myst==2.0.2 +jupyterlab-myst==2.1.0 jupyterlab-pygments==0.2.2 -jupyterlab-server==2.25.0 +jupyterlab-server==2.25.1 jupyterlab-widgets==3.0.9 kiwisolver==1.4.5 latexcodec==2.0.1 livereload==2.6.3 markdown-it-py==2.2.0 markupsafe==2.1.3 -matplotlib==3.8.0 +matplotlib==3.8.1 matplotlib-inline==0.1.6 mdit-py-plugins==0.3.5 mdurl==0.1.2 mistune==3.0.2 mpl-interactions==0.23.2 mpmath==1.3.0 -mypy==1.5.1 +mypy==1.6.1 mypy-extensions==1.0.0 myst-nb==0.17.2 myst-parser==0.18.1 nbclient==0.6.8 -nbconvert==7.9.2 +nbconvert==7.11.0 nbformat==5.9.2 -nbmake==1.4.5 +nbmake==1.4.6 nest-asyncio==1.5.8 nodeenv==1.8.0 notebook-shim==0.2.3 -numpy==1.26.0 +numpy==1.26.1 overrides==7.4.0 packaging==23.2 pandocfilters==1.5.0 @@ -109,24 +108,23 @@ parso==0.8.3 particle==0.23.0 pathspec==0.11.2 pexpect==4.8.0 -pickleshare==0.7.5 -pillow==10.0.1 +pillow==10.1.0 platformdirs==3.11.0 pluggy==1.3.0 -pre-commit==3.4.0 -prometheus-client==0.17.1 +pre-commit==3.5.0 +prometheus-client==0.18.0 prompt-toolkit==3.0.39 -psutil==5.9.5 +psutil==5.9.6 ptyprocess==0.7.0 pure-eval==0.2.2 pybtex==0.24.0 pybtex-docutils==1.0.3 pycparser==2.21 -pydata-sphinx-theme==0.14.1 +pydata-sphinx-theme==0.14.3 pygments==2.16.1 pyparsing==3.1.1 pyproject-api==1.6.1 -pytest==7.4.2 +pytest==7.4.3 pytest-cov==4.1.0 pytest-profiling==1.7.0 pytest-xdist==3.3.1 @@ -134,8 +132,8 @@ python-constraint==1.4.0 python-dateutil==2.8.2 python-json-logger==2.0.7 python-lsp-jsonrpc==1.1.2 -python-lsp-server==1.8.2 -pytoolconfig==1.2.5 +python-lsp-server==1.9.0 +pytoolconfig==1.2.6 pyyaml==6.0.1 pyzmq==25.1.1 qrules==0.9.8 @@ -144,9 +142,9 @@ requests==2.31.0 rfc3339-validator==0.1.4 rfc3986-validator==0.1.1 rich==13.6.0 -rope==1.10.0 -rpds-py==0.10.4 -ruff==0.0.292 +rope==1.11.0 +rpds-py==0.12.0 +ruff==0.1.4 send2trash==1.8.2 six==1.16.0 sniffio==1.3.0 @@ -160,7 +158,7 @@ sphinx-comments==0.0.3 sphinx-copybutton==0.5.2 sphinx-design==0.5.0 sphinx-hep-pdgref==0.2.0 -sphinx-thebe==0.2.1 +sphinx-thebe==0.3.0 sphinx-togglebutton==0.3.2 sphinxcontrib-applehelp==1.0.7 sphinxcontrib-bibtex==2.6.1 @@ -169,7 +167,7 @@ sphinxcontrib-htmlhelp==2.0.4 sphinxcontrib-jsmath==1.0.1 sphinxcontrib-qthelp==1.0.6 sphinxcontrib-serializinghtml==1.1.9 -sqlalchemy==2.0.21 +sqlalchemy==2.0.23 stack-data==0.6.3 sympy==1.12 tabulate==0.9.0 @@ -178,22 +176,22 @@ tinycss2==1.2.1 tornado==6.3.3 tox==4.11.3 tqdm==4.66.1 -traitlets==5.11.2 +traitlets==5.13.0 types-docutils==0.20.0.3 types-pkg-resources==0.1.3 types-python-dateutil==2.8.19.14 -types-requests==2.31.0.8 +types-requests==2.31.0.10 types-setuptools==68.2.0.0 typing-extensions==4.8.0 ujson==5.8.0 uri-template==1.3.0 -urllib3==2.0.6 -virtualenv==20.24.5 -wcwidth==0.2.8 +urllib3==2.0.7 +virtualenv==20.24.6 +wcwidth==0.2.9 webcolors==1.13 webencodings==0.5.1 websocket-client==1.6.4 -wheel==0.41.2 +wheel==0.41.3 widgetsnbextension==4.0.9 wrapt==1.15.0 zipp==3.17.0 diff --git a/.constraints/py3.7.txt b/.constraints/py3.7.txt index 90c106eeb..c194613ef 100644 --- a/.constraints/py3.7.txt +++ b/.constraints/py3.7.txt @@ -13,18 +13,18 @@ argon2-cffi==23.1.0 argon2-cffi-bindings==21.2.0 arrow==1.2.3 attrs==23.1.0 -babel==2.13.0 +babel==2.13.1 backcall==0.2.0 beautifulsoup4==4.12.2 black==23.3.0 bleach==6.0.0 cached-property==1.5.2 -cachetools==5.3.1 +cachetools==5.3.2 certifi==2023.7.22 cffi==1.15.1 cfgv==3.3.1 chardet==5.2.0 -charset-normalizer==3.3.0 +charset-normalizer==3.3.2 click==8.1.7 colorama==0.4.6 comm==0.1.4 @@ -35,7 +35,7 @@ decorator==5.1.1 defusedxml==0.7.1 deprecated==1.2.14 distlib==0.3.7 -docstring-to-markdown==0.12 +docstring-to-markdown==0.13 docutils==0.17.1 entrypoints==0.4 exceptiongroup==1.1.3 @@ -46,7 +46,7 @@ fonttools==4.38.0 fqdn==1.5.1 gprof2dot==2022.7.29 graphviz==0.20.1 -greenlet==3.0.0 +greenlet==3.0.1 hepunits==2.3.2 identify==2.5.24 idna==3.4 @@ -121,7 +121,7 @@ pluggy==1.2.0 pre-commit==2.21.0 prometheus-client==0.17.1 prompt-toolkit==3.0.39 -psutil==5.9.5 +psutil==5.9.6 ptyprocess==0.7.0 pybtex==0.24.0 pybtex-docutils==1.0.3 @@ -132,7 +132,7 @@ pygments==2.16.1 pyparsing==3.1.1 pyproject-api==1.5.3 pyrsistent==0.19.3 -pytest==7.4.2 +pytest==7.4.3 pytest-cov==4.1.0 pytest-profiling==1.7.0 pytest-xdist==3.3.1 @@ -141,7 +141,7 @@ python-dateutil==2.8.2 python-json-logger==2.0.7 python-lsp-jsonrpc==1.0.0 python-lsp-server==1.7.4 -pytoolconfig==1.2.5 +pytoolconfig==1.2.6 pytz==2023.3.post1 pyyaml==6.0.1 pyzmq==24.0.1 @@ -151,7 +151,7 @@ rfc3339-validator==0.1.4 rfc3986-validator==0.1.1 rich==13.6.0 rope==1.9.0 -ruff==0.0.292 +ruff==0.1.4 send2trash==1.8.2 singledispatchmethod==1.0 ; python_version < "3.8.0" six==1.16.0 @@ -175,7 +175,7 @@ sphinxcontrib-htmlhelp==2.0.0 sphinxcontrib-jsmath==1.0.1 sphinxcontrib-qthelp==1.0.3 sphinxcontrib-serializinghtml==1.1.5 -sqlalchemy==1.4.49 +sqlalchemy==1.4.50 sympy==1.10.1 tabulate==0.9.0 terminado==0.17.1 @@ -188,18 +188,18 @@ traitlets==5.9.0 typed-ast==1.5.5 types-docutils==0.20.0.3 types-pkg-resources==0.1.3 -types-requests==2.31.0.8 +types-requests==2.31.0.10 types-setuptools==68.2.0.0 typing-extensions==4.7.1 ; python_version < "3.8.0" ujson==5.7.0 uri-template==1.3.0 -urllib3==2.0.6 -virtualenv==20.24.5 -wcwidth==0.2.8 +urllib3==2.0.7 +virtualenv==20.24.6 +wcwidth==0.2.9 webcolors==1.13 webencodings==0.5.1 websocket-client==1.6.1 -wheel==0.41.2 +wheel==0.41.3 widgetsnbextension==4.0.9 wrapt==1.15.0 y-py==0.5.9 diff --git a/.constraints/py3.8.txt b/.constraints/py3.8.txt index 2f7844602..0a7d0a21e 100644 --- a/.constraints/py3.8.txt +++ b/.constraints/py3.8.txt @@ -10,23 +10,23 @@ anyio==4.0.0 argon2-cffi==23.1.0 argon2-cffi-bindings==21.2.0 arrow==1.3.0 -asttokens==2.4.0 +asttokens==2.4.1 async-lru==2.0.4 attrs==23.1.0 -babel==2.13.0 +babel==2.13.1 backcall==0.2.0 beautifulsoup4==4.12.2 -black==23.9.1 +black==23.11.0 bleach==6.1.0 -cachetools==5.3.1 +cachetools==5.3.2 certifi==2023.7.22 cffi==1.16.0 cfgv==3.4.0 chardet==5.2.0 -charset-normalizer==3.3.0 +charset-normalizer==3.3.2 click==8.1.7 colorama==0.4.6 -comm==0.1.4 +comm==0.2.0 contourpy==1.1.1 coverage==7.3.2 cycler==0.12.1 @@ -35,26 +35,26 @@ decorator==5.1.1 defusedxml==0.7.1 deprecated==1.2.14 distlib==0.3.7 -docstring-to-markdown==0.12 +docstring-to-markdown==0.13 docutils==0.17.1 exceptiongroup==1.1.3 execnet==2.0.2 -executing==2.0.0 +executing==2.0.1 fastjsonschema==2.18.1 -filelock==3.12.4 -fonttools==4.43.1 +filelock==3.13.1 +fonttools==4.44.0 fqdn==1.5.1 gprof2dot==2022.7.29 graphviz==0.20.1 -greenlet==3.0.0 +greenlet==3.0.1 hepunits==2.3.2 -identify==2.5.30 +identify==2.5.31 idna==3.4 imagesize==1.4.1 importlib-metadata==6.8.0 -importlib-resources==6.1.0 +importlib-resources==6.1.1 iniconfig==2.0.0 -ipykernel==6.25.2 +ipykernel==6.26.0 ipympl==0.9.3 ipython==8.12.3 ipython-genutils==0.2.0 @@ -64,21 +64,21 @@ jedi==0.19.1 jinja2==3.1.2 json5==0.9.14 jsonpointer==2.4 -jsonschema==4.19.1 +jsonschema==4.19.2 jsonschema-specifications==2023.7.1 jupyter-cache==0.6.1 -jupyter-client==8.3.1 -jupyter-core==5.3.2 -jupyter-events==0.7.0 +jupyter-client==8.6.0 +jupyter-core==5.5.0 +jupyter-events==0.9.0 jupyter-lsp==2.2.0 -jupyter-server==2.7.3 +jupyter-server==2.10.0 jupyter-server-terminals==0.4.4 -jupyterlab==4.0.6 +jupyterlab==4.0.8 jupyterlab-code-formatter==2.2.1 jupyterlab-lsp==5.0.0 -jupyterlab-myst==2.0.2 +jupyterlab-myst==2.1.0 jupyterlab-pygments==0.2.2 -jupyterlab-server==2.25.0 +jupyterlab-server==2.25.1 jupyterlab-widgets==3.0.9 kiwisolver==1.4.5 latexcodec==2.0.1 @@ -92,14 +92,14 @@ mdurl==0.1.2 mistune==3.0.2 mpl-interactions==0.23.2 mpmath==1.3.0 -mypy==1.5.1 +mypy==1.6.1 mypy-extensions==1.0.0 myst-nb==0.17.2 myst-parser==0.18.1 nbclient==0.6.8 -nbconvert==7.9.2 +nbconvert==7.11.0 nbformat==5.9.2 -nbmake==1.4.5 +nbmake==1.4.6 nest-asyncio==1.5.8 nodeenv==1.8.0 notebook-shim==0.2.3 @@ -112,24 +112,24 @@ particle==0.23.0 pathspec==0.11.2 pexpect==4.8.0 pickleshare==0.7.5 -pillow==10.0.1 +pillow==10.1.0 pkgutil-resolve-name==1.3.10 platformdirs==3.11.0 pluggy==1.3.0 -pre-commit==3.4.0 -prometheus-client==0.17.1 +pre-commit==3.5.0 +prometheus-client==0.18.0 prompt-toolkit==3.0.39 -psutil==5.9.5 +psutil==5.9.6 ptyprocess==0.7.0 pure-eval==0.2.2 pybtex==0.24.0 pybtex-docutils==1.0.3 pycparser==2.21 -pydata-sphinx-theme==0.14.1 +pydata-sphinx-theme==0.14.3 pygments==2.16.1 pyparsing==3.1.1 pyproject-api==1.6.1 -pytest==7.4.2 +pytest==7.4.3 pytest-cov==4.1.0 pytest-profiling==1.7.0 pytest-xdist==3.3.1 @@ -137,8 +137,8 @@ python-constraint==1.4.0 python-dateutil==2.8.2 python-json-logger==2.0.7 python-lsp-jsonrpc==1.1.2 -python-lsp-server==1.8.2 -pytoolconfig==1.2.5 +python-lsp-server==1.9.0 +pytoolconfig==1.2.6 pytz==2023.3.post1 pyyaml==6.0.1 pyzmq==25.1.1 @@ -148,9 +148,9 @@ requests==2.31.0 rfc3339-validator==0.1.4 rfc3986-validator==0.1.1 rich==13.6.0 -rope==1.10.0 -rpds-py==0.10.4 -ruff==0.0.292 +rope==1.11.0 +rpds-py==0.12.0 +ruff==0.1.4 send2trash==1.8.2 six==1.16.0 sniffio==1.3.0 @@ -164,7 +164,7 @@ sphinx-comments==0.0.3 sphinx-copybutton==0.5.2 sphinx-design==0.5.0 sphinx-hep-pdgref==0.2.0 -sphinx-thebe==0.2.1 +sphinx-thebe==0.3.0 sphinx-togglebutton==0.3.2 sphinxcontrib-applehelp==1.0.4 sphinxcontrib-bibtex==2.6.1 @@ -173,7 +173,7 @@ sphinxcontrib-htmlhelp==2.0.1 sphinxcontrib-jsmath==1.0.1 sphinxcontrib-qthelp==1.0.3 sphinxcontrib-serializinghtml==1.1.5 -sqlalchemy==2.0.21 +sqlalchemy==2.0.23 stack-data==0.6.3 sympy==1.12 tabulate==0.9.0 @@ -183,22 +183,22 @@ tomli==2.0.1 tornado==6.3.3 tox==4.11.3 tqdm==4.66.1 -traitlets==5.11.2 +traitlets==5.13.0 types-docutils==0.20.0.3 types-pkg-resources==0.1.3 types-python-dateutil==2.8.19.14 -types-requests==2.31.0.8 +types-requests==2.31.0.10 types-setuptools==68.2.0.0 typing-extensions==4.8.0 ujson==5.8.0 uri-template==1.3.0 -urllib3==2.0.6 -virtualenv==20.24.5 -wcwidth==0.2.8 +urllib3==2.0.7 +virtualenv==20.24.6 +wcwidth==0.2.9 webcolors==1.13 webencodings==0.5.1 websocket-client==1.6.4 -wheel==0.41.2 +wheel==0.41.3 widgetsnbextension==4.0.9 wrapt==1.15.0 zipp==3.17.0 diff --git a/.constraints/py3.9.txt b/.constraints/py3.9.txt index 00e5a82eb..abbbefbf1 100644 --- a/.constraints/py3.9.txt +++ b/.constraints/py3.9.txt @@ -10,24 +10,23 @@ anyio==4.0.0 argon2-cffi==23.1.0 argon2-cffi-bindings==21.2.0 arrow==1.3.0 -asttokens==2.4.0 +asttokens==2.4.1 async-lru==2.0.4 attrs==23.1.0 -babel==2.13.0 -backcall==0.2.0 +babel==2.13.1 beautifulsoup4==4.12.2 -black==23.9.1 +black==23.11.0 bleach==6.1.0 -cachetools==5.3.1 +cachetools==5.3.2 certifi==2023.7.22 cffi==1.16.0 cfgv==3.4.0 chardet==5.2.0 -charset-normalizer==3.3.0 +charset-normalizer==3.3.2 click==8.1.7 colorama==0.4.6 -comm==0.1.4 -contourpy==1.1.1 +comm==0.2.0 +contourpy==1.2.0 coverage==7.3.2 cycler==0.12.1 debugpy==1.8.0 @@ -35,28 +34,28 @@ decorator==5.1.1 defusedxml==0.7.1 deprecated==1.2.14 distlib==0.3.7 -docstring-to-markdown==0.12 +docstring-to-markdown==0.13 docutils==0.17.1 exceptiongroup==1.1.3 execnet==2.0.2 -executing==2.0.0 +executing==2.0.1 fastjsonschema==2.18.1 -filelock==3.12.4 -fonttools==4.43.1 +filelock==3.13.1 +fonttools==4.44.0 fqdn==1.5.1 gprof2dot==2022.7.29 graphviz==0.20.1 -greenlet==3.0.0 +greenlet==3.0.1 hepunits==2.3.2 -identify==2.5.30 +identify==2.5.31 idna==3.4 imagesize==1.4.1 importlib-metadata==6.8.0 -importlib-resources==6.1.0 +importlib-resources==6.1.1 iniconfig==2.0.0 -ipykernel==6.25.2 +ipykernel==6.26.0 ipympl==0.9.3 -ipython==8.16.1 +ipython==8.17.2 ipython-genutils==0.2.0 ipywidgets==8.1.1 isoduration==20.11.0 @@ -64,46 +63,46 @@ jedi==0.19.1 jinja2==3.1.2 json5==0.9.14 jsonpointer==2.4 -jsonschema==4.19.1 +jsonschema==4.19.2 jsonschema-specifications==2023.7.1 jupyter-cache==0.6.1 -jupyter-client==8.3.1 -jupyter-core==5.3.2 -jupyter-events==0.7.0 +jupyter-client==8.6.0 +jupyter-core==5.5.0 +jupyter-events==0.9.0 jupyter-lsp==2.2.0 -jupyter-server==2.7.3 +jupyter-server==2.10.0 jupyter-server-terminals==0.4.4 -jupyterlab==4.0.6 +jupyterlab==4.0.8 jupyterlab-code-formatter==2.2.1 jupyterlab-lsp==5.0.0 -jupyterlab-myst==2.0.2 +jupyterlab-myst==2.1.0 jupyterlab-pygments==0.2.2 -jupyterlab-server==2.25.0 +jupyterlab-server==2.25.1 jupyterlab-widgets==3.0.9 kiwisolver==1.4.5 latexcodec==2.0.1 livereload==2.6.3 markdown-it-py==2.2.0 markupsafe==2.1.3 -matplotlib==3.8.0 +matplotlib==3.8.1 matplotlib-inline==0.1.6 mdit-py-plugins==0.3.5 mdurl==0.1.2 mistune==3.0.2 mpl-interactions==0.23.2 mpmath==1.3.0 -mypy==1.5.1 +mypy==1.6.1 mypy-extensions==1.0.0 myst-nb==0.17.2 myst-parser==0.18.1 nbclient==0.6.8 -nbconvert==7.9.2 +nbconvert==7.11.0 nbformat==5.9.2 -nbmake==1.4.5 +nbmake==1.4.6 nest-asyncio==1.5.8 nodeenv==1.8.0 notebook-shim==0.2.3 -numpy==1.26.0 +numpy==1.26.1 overrides==7.4.0 packaging==23.2 pandocfilters==1.5.0 @@ -111,24 +110,23 @@ parso==0.8.3 particle==0.23.0 pathspec==0.11.2 pexpect==4.8.0 -pickleshare==0.7.5 -pillow==10.0.1 +pillow==10.1.0 platformdirs==3.11.0 pluggy==1.3.0 -pre-commit==3.4.0 -prometheus-client==0.17.1 +pre-commit==3.5.0 +prometheus-client==0.18.0 prompt-toolkit==3.0.39 -psutil==5.9.5 +psutil==5.9.6 ptyprocess==0.7.0 pure-eval==0.2.2 pybtex==0.24.0 pybtex-docutils==1.0.3 pycparser==2.21 -pydata-sphinx-theme==0.14.1 +pydata-sphinx-theme==0.14.3 pygments==2.16.1 pyparsing==3.1.1 pyproject-api==1.6.1 -pytest==7.4.2 +pytest==7.4.3 pytest-cov==4.1.0 pytest-profiling==1.7.0 pytest-xdist==3.3.1 @@ -136,8 +134,8 @@ python-constraint==1.4.0 python-dateutil==2.8.2 python-json-logger==2.0.7 python-lsp-jsonrpc==1.1.2 -python-lsp-server==1.8.2 -pytoolconfig==1.2.5 +python-lsp-server==1.9.0 +pytoolconfig==1.2.6 pyyaml==6.0.1 pyzmq==25.1.1 qrules==0.9.8 @@ -146,9 +144,9 @@ requests==2.31.0 rfc3339-validator==0.1.4 rfc3986-validator==0.1.1 rich==13.6.0 -rope==1.10.0 -rpds-py==0.10.4 -ruff==0.0.292 +rope==1.11.0 +rpds-py==0.12.0 +ruff==0.1.4 send2trash==1.8.2 six==1.16.0 sniffio==1.3.0 @@ -162,7 +160,7 @@ sphinx-comments==0.0.3 sphinx-copybutton==0.5.2 sphinx-design==0.5.0 sphinx-hep-pdgref==0.2.0 -sphinx-thebe==0.2.1 +sphinx-thebe==0.3.0 sphinx-togglebutton==0.3.2 sphinxcontrib-applehelp==1.0.7 sphinxcontrib-bibtex==2.6.1 @@ -171,7 +169,7 @@ sphinxcontrib-htmlhelp==2.0.4 sphinxcontrib-jsmath==1.0.1 sphinxcontrib-qthelp==1.0.6 sphinxcontrib-serializinghtml==1.1.9 -sqlalchemy==2.0.21 +sqlalchemy==2.0.23 stack-data==0.6.3 sympy==1.12 tabulate==0.9.0 @@ -181,22 +179,22 @@ tomli==2.0.1 tornado==6.3.3 tox==4.11.3 tqdm==4.66.1 -traitlets==5.11.2 +traitlets==5.13.0 types-docutils==0.20.0.3 types-pkg-resources==0.1.3 types-python-dateutil==2.8.19.14 -types-requests==2.31.0.8 +types-requests==2.31.0.10 types-setuptools==68.2.0.0 typing-extensions==4.8.0 ujson==5.8.0 uri-template==1.3.0 -urllib3==2.0.6 -virtualenv==20.24.5 -wcwidth==0.2.8 +urllib3==2.0.7 +virtualenv==20.24.6 +wcwidth==0.2.9 webcolors==1.13 webencodings==0.5.1 websocket-client==1.6.4 -wheel==0.41.2 +wheel==0.41.3 widgetsnbextension==4.0.9 wrapt==1.15.0 zipp==3.17.0 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5a818e132..25f7a094c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -38,7 +38,7 @@ repos: - id: trailing-whitespace - repo: https://github.com/ComPWA/repo-maintenance - rev: 0.1.0 + rev: 0.1.1 hooks: - id: check-dev-files args: @@ -65,8 +65,8 @@ repos: args: - --fix - - repo: https://github.com/psf/black - rev: 23.9.1 + - repo: https://github.com/psf/black-pre-commit-mirror + rev: 23.11.0 hooks: - id: black - id: black-jupyter @@ -79,7 +79,7 @@ repos: - id: blacken-docs - repo: https://github.com/python-jsonschema/check-jsonschema - rev: 0.27.0 + rev: 0.27.1 hooks: - id: check-jsonschema name: Check CITATION.cff @@ -92,12 +92,12 @@ repos: pass_filenames: false - repo: https://github.com/streetsidesoftware/cspell-cli - rev: v7.3.1 + rev: v8.0.0 hooks: - id: cspell - repo: https://github.com/editorconfig-checker/editorconfig-checker.python - rev: 2.7.2 + rev: 2.7.3 hooks: - id: editorconfig-checker name: editorconfig @@ -148,7 +148,7 @@ repos: - id: prettier - repo: https://github.com/ComPWA/mirrors-pyright - rev: v1.1.330 + rev: v1.1.334 hooks: - id: pyright @@ -160,7 +160,7 @@ repos: - --py37-plus - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.0.292 + rev: v0.1.4 hooks: - id: ruff args: diff --git a/docs/_extend_docstrings.py b/docs/_extend_docstrings.py index aef4112a0..07e47f858 100644 --- a/docs/_extend_docstrings.py +++ b/docs/_extend_docstrings.py @@ -2,6 +2,7 @@ This small script is used by ``conf.py`` to dynamically modify docstrings. """ + # pyright: reportMissingImports=false from __future__ import annotations diff --git a/docs/_relink_references.py b/docs/_relink_references.py index d3f009261..8830b0927 100644 --- a/docs/_relink_references.py +++ b/docs/_relink_references.py @@ -5,6 +5,7 @@ See also https://github.com/sphinx-doc/sphinx/issues/5868. """ + # pyright: reportMissingImports=false from __future__ import annotations diff --git a/docs/conf.py b/docs/conf.py index 4bfd15c54..9104ab0bb 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -3,6 +3,7 @@ This file only contains a selection of the most common options. For a full list see the documentation: https://www.sphinx-doc.org/en/master/usage/configuration.html """ + # pyright: reportMissingImports=false # pyright: reportUntypedBaseClass=false # pyright: reportUntypedFunctionDecorator=false @@ -98,19 +99,17 @@ def fetch_logo(url: str, output_path: str) -> None: shutil.rmtree("api", ignore_errors=True) subprocess.call( - " ".join( - [ - "sphinx-apidoc", - f"../src/{PACKAGE}/", - f"../src/{PACKAGE}/version.py", - f"../src/{PACKAGE}/io/latex.py", - "-o api/", - "--force", - "--no-toc", - "--templatedir _templates", - "--separate", - ] - ), + " ".join([ + "sphinx-apidoc", + f"../src/{PACKAGE}/", + f"../src/{PACKAGE}/version.py", + f"../src/{PACKAGE}/io/latex.py", + "-o api/", + "--force", + "--no-toc", + "--templatedir _templates", + "--separate", + ]), shell=True, # noqa: S602 ) @@ -156,28 +155,24 @@ def fetch_logo(url: str, output_path: str) -> None: # General sphinx settings add_module_names = False autodoc_default_options = { - "exclude-members": ", ".join( - [ - "as_explicit", - "default_assumptions", - "doit", - "evaluate", - "is_commutative", - "is_extended_real", - "items", - "keys", - "precedence", - "values", - ] - ), + "exclude-members": ", ".join([ + "as_explicit", + "default_assumptions", + "doit", + "evaluate", + "is_commutative", + "is_extended_real", + "items", + "keys", + "precedence", + "values", + ]), "members": True, "undoc-members": True, "show-inheritance": True, - "special-members": ", ".join( - [ - "__call__", - ] - ), + "special-members": ", ".join([ + "__call__", + ]), } autodoc_member_order = "bysource" autodoc_type_aliases = { diff --git a/docs/usage/dynamics/k-matrix.ipynb b/docs/usage/dynamics/k-matrix.ipynb index 94991163e..7854630f0 100644 --- a/docs/usage/dynamics/k-matrix.ipynb +++ b/docs/usage/dynamics/k-matrix.ipynb @@ -935,12 +935,10 @@ "rel_k_matrix_2r = symplot.substitute_indexed_symbols(rel_k_matrix_2r)\n", "s, m_a, m_b = sp.symbols(\"s, m_a0, m_b0\", nonnegative=True)\n", "rho = PhaseSpaceFactor(s, m_a, m_b)\n", - "rel_k_matrix_2r = rel_k_matrix_2r.xreplace(\n", - " {\n", - " sp.sqrt(rho): 1,\n", - " sp.conjugate(sp.sqrt(rho)): 1,\n", - " }\n", - ")\n", + "rel_k_matrix_2r = rel_k_matrix_2r.xreplace({\n", + " sp.sqrt(rho): 1,\n", + " sp.conjugate(sp.sqrt(rho)): 1,\n", + "})\n", "denominator, nominator = rel_k_matrix_2r.args\n", "term1 = nominator.args[0] * denominator\n", "term2 = nominator.args[1] * denominator\n", @@ -1050,12 +1048,10 @@ "rel_f_vector_1r = symplot.substitute_indexed_symbols(rel_f_vector_1r)\n", "s, m_a, m_b = sp.symbols(\"s, m_a0, m_b0\", nonnegative=True)\n", "rho = PhaseSpaceFactor(s, m_a, m_b)\n", - "rel_f_vector_1r.xreplace(\n", - " {\n", - " sp.sqrt(rho): 1,\n", - " sp.conjugate(sp.sqrt(rho)): 1,\n", - " }\n", - ").simplify(doit=False)" + "rel_f_vector_1r.xreplace({\n", + " sp.sqrt(rho): 1,\n", + " sp.conjugate(sp.sqrt(rho)): 1,\n", + "}).simplify(doit=False)" ] }, { @@ -1496,9 +1492,9 @@ " *sp.symbols(f\"s m_a{i} m_b{i}\", nonnegative=True)\n", " ).doit()\n", "\n", - " expr = expr.xreplace(\n", - " {sp.sqrt(rho_i(i)): 1 for i in range(n_channels)}\n", - " ).xreplace({sp.conjugate(sp.sqrt(rho_i(i))): 1 for i in range(n_channels)})\n", + " expr = expr.xreplace({\n", + " sp.sqrt(rho_i(i)): 1 for i in range(n_channels)\n", + " }).xreplace({sp.conjugate(sp.sqrt(rho_i(i))): 1 for i in range(n_channels)})\n", " expr = expr.xreplace({s: m**2})\n", " expr = symplot.substitute_indexed_symbols(expr)\n", " np_expr, sliders = symplot.prepare_sliders(expr, m)\n", @@ -1528,42 +1524,34 @@ " kmatrix.RelativisticKMatrix,\n", " kmatrix.RelativisticPVector,\n", " }:\n", - " sliders.set_ranges(\n", - " {\n", - " f\"m{R}\": (0, 3, 100),\n", - " Rf\"\\Gamma_{{{R},{i}}}\": (-2, +2, 100),\n", - " Rf\"\\gamma_{{{R},{i}}}\": (0, 10, 100),\n", - " f\"m_a{i}\": (0, 1, 0.01),\n", - " f\"m_b{i}\": (0, 1, 0.01),\n", - " }\n", - " )\n", - " sliders.set_values(\n", - " {\n", - " f\"m{R}\": m0_values[R - 1],\n", - " Rf\"\\Gamma_{{{R},{i}}}\": 2.0 * (0.4 + R * 0.2 - i * 0.3),\n", - " Rf\"\\gamma_{{{R},{i}}}\": 0.25 * (10 - R + i),\n", - " f\"m_a{i}\": (i + 1) * 0.25,\n", - " f\"m_b{i}\": (i + 1) * 0.25,\n", - " }\n", - " )\n", + " sliders.set_ranges({\n", + " f\"m{R}\": (0, 3, 100),\n", + " Rf\"\\Gamma_{{{R},{i}}}\": (-2, +2, 100),\n", + " Rf\"\\gamma_{{{R},{i}}}\": (0, 10, 100),\n", + " f\"m_a{i}\": (0, 1, 0.01),\n", + " f\"m_b{i}\": (0, 1, 0.01),\n", + " })\n", + " sliders.set_values({\n", + " f\"m{R}\": m0_values[R - 1],\n", + " Rf\"\\Gamma_{{{R},{i}}}\": 2.0 * (0.4 + R * 0.2 - i * 0.3),\n", + " Rf\"\\gamma_{{{R},{i}}}\": 0.25 * (10 - R + i),\n", + " f\"m_a{i}\": (i + 1) * 0.25,\n", + " f\"m_b{i}\": (i + 1) * 0.25,\n", + " })\n", " if kmatrix_type in {\n", " kmatrix.NonRelativisticPVector,\n", " kmatrix.NonRelativisticKMatrix,\n", " }:\n", - " sliders.set_ranges(\n", - " {\n", - " f\"m{R}\": (0, 3, 100),\n", - " Rf\"\\Gamma_{{{R},{i}}}\": (-1, 1, 100),\n", - " Rf\"\\gamma_{{{R},{i}}}\": (0, 2, 100),\n", - " }\n", - " )\n", - " sliders.set_values(\n", - " {\n", - " f\"m{R}\": m0_values[R - 1],\n", - " Rf\"\\Gamma_{{{R},{i}}}\": (R + 1) * 0.1,\n", - " Rf\"\\gamma_{{{R},{i}}}\": 1 - 0.1 * R + 0.1 * i,\n", - " }\n", - " )\n", + " sliders.set_ranges({\n", + " f\"m{R}\": (0, 3, 100),\n", + " Rf\"\\Gamma_{{{R},{i}}}\": (-1, 1, 100),\n", + " Rf\"\\gamma_{{{R},{i}}}\": (0, 2, 100),\n", + " })\n", + " sliders.set_values({\n", + " f\"m{R}\": m0_values[R - 1],\n", + " Rf\"\\Gamma_{{{R},{i}}}\": (R + 1) * 0.1,\n", + " Rf\"\\gamma_{{{R},{i}}}\": 1 - 0.1 * R + 0.1 * i,\n", + " })\n", " if kmatrix_type in {\n", " kmatrix.NonRelativisticPVector,\n", " kmatrix.RelativisticPVector,\n", diff --git a/docs/usage/interactive.ipynb b/docs/usage/interactive.ipynb index a01463b9f..b4dfa73f5 100644 --- a/docs/usage/interactive.ipynb +++ b/docs/usage/interactive.ipynb @@ -356,18 +356,16 @@ "outputs": [], "source": [ "n_steps = 100\n", - "sliders.set_ranges(\n", - " {\n", - " \"m_{f_{0}(980)}\": (0.3, 1.8, n_steps),\n", - " \"m_{f_{0}(1500)}\": (0.3, 1.8, n_steps),\n", - " R\"\\Gamma_{f_{0}(980)}\": (0.01, 1, n_steps),\n", - " R\"\\Gamma_{f_{0}(1500)}\": (0.01, 1, n_steps),\n", - " \"m_1\": (0.01, 1, n_steps),\n", - " \"m_2\": (0.01, 1, n_steps),\n", - " \"phi_0\": (0, 2 * np.pi, 40),\n", - " \"theta_0\": (-np.pi, np.pi, 40),\n", - " }\n", - ")" + "sliders.set_ranges({\n", + " \"m_{f_{0}(980)}\": (0.3, 1.8, n_steps),\n", + " \"m_{f_{0}(1500)}\": (0.3, 1.8, n_steps),\n", + " R\"\\Gamma_{f_{0}(980)}\": (0.01, 1, n_steps),\n", + " R\"\\Gamma_{f_{0}(1500)}\": (0.01, 1, n_steps),\n", + " \"m_1\": (0.01, 1, n_steps),\n", + " \"m_2\": (0.01, 1, n_steps),\n", + " \"phi_0\": (0, 2 * np.pi, 40),\n", + " \"theta_0\": (-np.pi, np.pi, 40),\n", + "})" ] }, { diff --git a/docs/usage/kinematics.ipynb b/docs/usage/kinematics.ipynb index bce2acad7..e9a0fb71e 100644 --- a/docs/usage/kinematics.ipynb +++ b/docs/usage/kinematics.ipynb @@ -182,13 +182,11 @@ "import numpy as np\n", "\n", "pz_array = np.array([[3.0971, 0, 0, 30e-3]]) # J/psi in BESIII lab frame\n", - "q_array = np.array(\n", - " [\n", - " [2.4, 0.3, -1.5, 0.02],\n", - " [3.4, -0.045, 0.6, 1.1],\n", - " # list of measured four-momenta q in lab frame\n", - " ]\n", - ")\n", + "q_array = np.array([\n", + " [2.4, 0.3, -1.5, 0.02],\n", + " [3.4, -0.045, 0.6, 1.1],\n", + " # list of measured four-momenta q in lab frame\n", + "])\n", "Bz_func(pz_array, q_array)" ] }, diff --git a/src/ampform/dynamics/__init__.py b/src/ampform/dynamics/__init__.py index cc75431eb..24aa38e07 100644 --- a/src/ampform/dynamics/__init__.py +++ b/src/ampform/dynamics/__init__.py @@ -2,6 +2,7 @@ .. seealso:: :doc:`/usage/dynamics` and :doc:`/usage/dynamics/analytic-continuation` """ + # cspell:ignore asner mhash from __future__ import annotations @@ -86,14 +87,7 @@ def evaluate(self) -> sp.Expr: 5: ( 998881 * z**5 - / ( - z**5 - + 15 * z**4 - + 315 * z**3 - + 6300 * z**2 - + 99225 * z - + 893025 - ) + / (z**5 + 15 * z**4 + 315 * z**3 + 6300 * z**2 + 99225 * z + 893025) ), 6: ( 118394977 @@ -138,14 +132,11 @@ def evaluate(self) -> sp.Expr: ) ), } - return sp.Piecewise( - *[ - (expression, sp.Eq(angular_momentum, value)) - for value, expression in cases.items() - if self.max_angular_momentum is None - or value <= self.max_angular_momentum - ] - ) + return sp.Piecewise(*[ + (expression, sp.Eq(angular_momentum, value)) + for value, expression in cases.items() + if self.max_angular_momentum is None or value <= self.max_angular_momentum + ]) def _latex(self, printer: LatexPrinter, *args) -> str: angular_momentum, z = tuple(map(printer._print, self.args)) @@ -312,7 +303,5 @@ def formulate_form_factor(s, m_a, m_b, angular_momentum, meson_radius) -> sp.Exp `~sympy.functions.elementary.miscellaneous.sqrt` of a `.BlattWeisskopfSquared`. """ q_squared = BreakupMomentumSquared(s, m_a, m_b) - ff_squared = BlattWeisskopfSquared( - angular_momentum, z=q_squared * meson_radius**2 - ) + ff_squared = BlattWeisskopfSquared(angular_momentum, z=q_squared * meson_radius**2) return sp.sqrt(ff_squared) diff --git a/src/ampform/dynamics/builder.py b/src/ampform/dynamics/builder.py index e06f61f0f..775823952 100644 --- a/src/ampform/dynamics/builder.py +++ b/src/ampform/dynamics/builder.py @@ -1,4 +1,5 @@ """Build `~ampform.dynamics` with correct variable names and values.""" + from __future__ import annotations import sys diff --git a/src/ampform/dynamics/kmatrix.py b/src/ampform/dynamics/kmatrix.py index 65a30e2c9..ff35981d6 100644 --- a/src/ampform/dynamics/kmatrix.py +++ b/src/ampform/dynamics/kmatrix.py @@ -7,6 +7,7 @@ keep the code organized and to enable caching of the matrix multiplications, but this might change once these dynamics are implemented into the amplitude builder. """ + from __future__ import annotations import functools @@ -78,32 +79,28 @@ def formulate( # type: ignore[override] # noqa: D417 s = sp.Symbol("s", nonnegative=True) m_a = sp.IndexedBase("m_a", nonnegative=True) m_b = sp.IndexedBase("m_b", nonnegative=True) - return t_matrix.xreplace( - { - k_matrix[i, j]: cls.parametrization( - i=i, - j=j, - s=s, - pole_position=sp.IndexedBase("m", nonnegative=True), - pole_width=sp.IndexedBase("Gamma", nonnegative=True), - m_a=m_a, - m_b=m_b, - residue_constant=sp.IndexedBase("gamma", nonnegative=True), - n_poles=n_poles, - pole_id=sp.Symbol("R", integer=True, positive=True), - angular_momentum=angular_momentum, - meson_radius=meson_radius, - phsp_factor=phsp_factor, - ) - for i in range(n_channels) - for j in range(n_channels) - } - ).xreplace( - { - sp.Symbol(f"rho{i}"): phsp_factor(s, m_a[i], m_b[i]) - for i in range(n_channels) - } - ) + return t_matrix.xreplace({ + k_matrix[i, j]: cls.parametrization( + i=i, + j=j, + s=s, + pole_position=sp.IndexedBase("m", nonnegative=True), + pole_width=sp.IndexedBase("Gamma", nonnegative=True), + m_a=m_a, + m_b=m_b, + residue_constant=sp.IndexedBase("gamma", nonnegative=True), + n_poles=n_poles, + pole_id=sp.Symbol("R", integer=True, positive=True), + angular_momentum=angular_momentum, + meson_radius=meson_radius, + phsp_factor=phsp_factor, + ) + for i in range(n_channels) + for j in range(n_channels) + }).xreplace({ + sp.Symbol(f"rho{i}"): phsp_factor(s, m_a[i], m_b[i]) + for i in range(n_channels) + }) @staticmethod def parametrization( @@ -163,22 +160,20 @@ def formulate( t_matrix, k_matrix = cls._create_matrices(n_channels) if not parametrize: return t_matrix - return t_matrix.xreplace( - { - k_matrix[i, j]: cls.parametrization( - i=i, - j=j, - s=sp.Symbol("s", nonnegative=True), - pole_position=sp.IndexedBase("m", nonnegative=True), - pole_width=sp.IndexedBase("Gamma", nonnegative=True), - residue_constant=sp.IndexedBase("gamma", nonnegative=True), - n_poles=n_poles, - pole_id=sp.Symbol("R", integer=True, positive=True), - ) - for i in range(n_channels) - for j in range(n_channels) - } - ) + return t_matrix.xreplace({ + k_matrix[i, j]: cls.parametrization( + i=i, + j=j, + s=sp.Symbol("s", nonnegative=True), + pole_position=sp.IndexedBase("m", nonnegative=True), + pole_width=sp.IndexedBase("Gamma", nonnegative=True), + residue_constant=sp.IndexedBase("gamma", nonnegative=True), + n_poles=n_poles, + pole_id=sp.Symbol("R", integer=True, positive=True), + ) + for i in range(n_channels) + for j in range(n_channels) + }) @staticmethod def parametrization( @@ -229,36 +224,32 @@ def formulate( pole_width = sp.IndexedBase("Gamma", nonnegative=True) residue_constant = sp.IndexedBase("gamma", nonnegative=True) pole_id = sp.Symbol("R", integer=True, positive=True) - return f_vector.xreplace( - { - k_matrix[i, j]: NonRelativisticKMatrix.parametrization( - i=i, - j=j, - s=s, - pole_position=pole_position, - pole_width=pole_width, - residue_constant=residue_constant, - n_poles=n_poles, - pole_id=pole_id, - ) - for i in range(n_channels) - for j in range(n_channels) - } - ).xreplace( - { - p_vector[i]: cls.parametrization( - i=i, - s=sp.Symbol("s", nonnegative=True), - pole_position=pole_position, - pole_width=pole_width, - residue_constant=residue_constant, - beta_constant=sp.IndexedBase("beta", nonnegative=True), - n_poles=n_poles, - pole_id=pole_id, - ) - for i in range(n_channels) - } - ) + return f_vector.xreplace({ + k_matrix[i, j]: NonRelativisticKMatrix.parametrization( + i=i, + j=j, + s=s, + pole_position=pole_position, + pole_width=pole_width, + residue_constant=residue_constant, + n_poles=n_poles, + pole_id=pole_id, + ) + for i in range(n_channels) + for j in range(n_channels) + }).xreplace({ + p_vector[i]: cls.parametrization( + i=i, + s=sp.Symbol("s", nonnegative=True), + pole_position=pole_position, + pole_width=pole_width, + residue_constant=residue_constant, + beta_constant=sp.IndexedBase("beta", nonnegative=True), + n_poles=n_poles, + pole_id=pole_id, + ) + for i in range(n_channels) + }) @staticmethod def parametrization( @@ -333,51 +324,45 @@ def formulate( # type: ignore[override] # noqa: D417 m_b = sp.IndexedBase("m_b", nonnegative=True) pole_id = sp.Symbol("R", integer=True, positive=True) return ( - f_vector.xreplace( - { - k_matrix[i, j]: RelativisticKMatrix.parametrization( - i=i, - j=j, - s=s, - pole_position=pole_position, - pole_width=pole_width, - m_a=m_a, - m_b=m_b, - residue_constant=residue_constant, - n_poles=n_poles, - pole_id=pole_id, - angular_momentum=angular_momentum, - meson_radius=meson_radius, - ) - for i in range(n_channels) - for j in range(n_channels) - } - ) - .xreplace( - { - p_vector[i]: cls.parametrization( - i=i, - s=s, - pole_position=pole_position, - pole_width=pole_width, - m_a=m_a, - m_b=m_b, - beta_constant=sp.IndexedBase("beta", nonnegative=True), - residue_constant=residue_constant, - n_poles=n_poles, - pole_id=pole_id, - angular_momentum=angular_momentum, - meson_radius=meson_radius, - ) - for i in range(n_channels) - } - ) - .xreplace( - { - sp.Symbol(f"rho{i}"): phsp_factor(s, m_a[i], m_b[i]) - for i in range(n_channels) - } - ) + f_vector.xreplace({ + k_matrix[i, j]: RelativisticKMatrix.parametrization( + i=i, + j=j, + s=s, + pole_position=pole_position, + pole_width=pole_width, + m_a=m_a, + m_b=m_b, + residue_constant=residue_constant, + n_poles=n_poles, + pole_id=pole_id, + angular_momentum=angular_momentum, + meson_radius=meson_radius, + ) + for i in range(n_channels) + for j in range(n_channels) + }) + .xreplace({ + p_vector[i]: cls.parametrization( + i=i, + s=s, + pole_position=pole_position, + pole_width=pole_width, + m_a=m_a, + m_b=m_b, + beta_constant=sp.IndexedBase("beta", nonnegative=True), + residue_constant=residue_constant, + n_poles=n_poles, + pole_id=pole_id, + angular_momentum=angular_momentum, + meson_radius=meson_radius, + ) + for i in range(n_channels) + }) + .xreplace({ + sp.Symbol(f"rho{i}"): phsp_factor(s, m_a[i], m_b[i]) + for i in range(n_channels) + }) ) @staticmethod diff --git a/src/ampform/dynamics/phasespace.py b/src/ampform/dynamics/phasespace.py index a662cfa2a..797cce276 100644 --- a/src/ampform/dynamics/phasespace.py +++ b/src/ampform/dynamics/phasespace.py @@ -9,6 +9,7 @@ `PhaseSpaceFactorProtocol`, so that they can be used in parametrizations like `.EnergyDependentWidth`. """ + from __future__ import annotations import sys @@ -213,9 +214,7 @@ def chew_mandelstam_s_wave(s, m_a, m_b): sp.log((m_a**2 + m_b**2 - s + 2 * sp.sqrt(s) * q) / (2 * m_a * m_b)), evaluate=False, ) - right_term = ( - (m_a**2 - m_b**2) * (1 / s - 1 / (m_a + m_b) ** 2) * sp.log(m_a / m_b) - ) + right_term = (m_a**2 - m_b**2) * (1 / s - 1 / (m_a + m_b) ** 2) * sp.log(m_a / m_b) # evaluate=False in order to keep same style as PDG return sp.Mul( 1 / (16 * sp.pi**2), diff --git a/src/ampform/helicity/__init__.py b/src/ampform/helicity/__init__.py index 47809a32c..8b86e357f 100644 --- a/src/ampform/helicity/__init__.py +++ b/src/ampform/helicity/__init__.py @@ -4,6 +4,7 @@ import sympy as sp """ + from __future__ import annotations import collections @@ -77,31 +78,27 @@ def _order_component_mapping( mapping: Mapping[str, sp.Expr] ) -> OrderedDict[str, sp.Expr]: - return collections.OrderedDict( - [(key, mapping[key]) for key in sorted(mapping, key=natural_sorting)] - ) + return collections.OrderedDict([ + (key, mapping[key]) for key in sorted(mapping, key=natural_sorting) + ]) def _order_symbol_mapping( mapping: Mapping[sp.Symbol, sp.Expr] ) -> OrderedDict[sp.Symbol, sp.Expr]: - return collections.OrderedDict( - [ - (symbol, mapping[symbol]) - for symbol in sorted(mapping, key=lambda s: natural_sorting(s.name)) - ] - ) + return collections.OrderedDict([ + (symbol, mapping[symbol]) + for symbol in sorted(mapping, key=lambda s: natural_sorting(s.name)) + ]) def _order_amplitudes( mapping: Mapping[sp.Indexed, sp.Expr] ) -> OrderedDict[sp.Indexed, sp.Expr]: - return collections.OrderedDict( - [ - (key, mapping[key]) - for key in sorted(mapping, key=lambda a: natural_sorting(str(a))) - ] - ) + return collections.OrderedDict([ + (key, mapping[key]) + for key in sorted(mapping, key=lambda a: natural_sorting(str(a))) + ]) def _to_parameter_values(mapping: Mapping[sp.Basic, ParameterValue]) -> ParameterValues: diff --git a/src/ampform/helicity/align/__init__.py b/src/ampform/helicity/align/__init__.py index 62ff16189..de10a9408 100644 --- a/src/ampform/helicity/align/__init__.py +++ b/src/ampform/helicity/align/__init__.py @@ -1,4 +1,5 @@ """Different formalisms for aligning amplitudes in different sub-systems.""" + from __future__ import annotations from abc import ABC, abstractmethod diff --git a/src/ampform/helicity/align/axisangle.py b/src/ampform/helicity/align/axisangle.py index bcc36504c..61cb6e153 100644 --- a/src/ampform/helicity/align/axisangle.py +++ b/src/ampform/helicity/align/axisangle.py @@ -3,6 +3,7 @@ See :cite:`marangottoHelicityAmplitudesGeneric2020` and `Wigner rotations `_. """ + from __future__ import annotations from typing import TYPE_CHECKING, Generator, Sequence, TypeVar, overload diff --git a/src/ampform/helicity/align/dpd.py b/src/ampform/helicity/align/dpd.py index 79138bb03..406fa3e1a 100644 --- a/src/ampform/helicity/align/dpd.py +++ b/src/ampform/helicity/align/dpd.py @@ -2,6 +2,7 @@ See :cite:`mikhasenkoDalitzplotDecompositionThreebody2020`. """ + from __future__ import annotations import sys @@ -129,9 +130,9 @@ def _(obj: ReactionInfo) -> ReactionInfo: # type: ignore[misc] @relabel_edge_ids.register(StateTransitionCollection) def _(obj: StateTransitionCollection) -> StateTransitionCollection: # type: ignore[misc] - return StateTransitionCollection( # no attrs.evolve() for __attrs_post_init__() - [relabel_edge_ids(transition) for transition in obj.transitions] - ) + return StateTransitionCollection([ # no attrs.evolve() for __attrs_post_init__() + relabel_edge_ids(transition) for transition in obj.transitions + ]) @relabel_edge_ids.register(StateTransition) @@ -159,11 +160,9 @@ def _collect_outer_state_helicities( ) -> dict[int, list[sp.Rational]]: outer_state_ids = get_outer_state_ids(reaction) return { - i: sorted( - { - sp.Rational(transition.states[i].spin_projection) - for transition in reaction.transitions - } - ) + i: sorted({ + sp.Rational(transition.states[i].spin_projection) + for transition in reaction.transitions + }) for i in outer_state_ids } diff --git a/src/ampform/helicity/decay.py b/src/ampform/helicity/decay.py index c2e715583..9a1221681 100644 --- a/src/ampform/helicity/decay.py +++ b/src/ampform/helicity/decay.py @@ -1,4 +1,5 @@ """Extract two-body decay info from a `~qrules.transition.StateTransition`.""" + from __future__ import annotations import collections diff --git a/src/ampform/helicity/naming.py b/src/ampform/helicity/naming.py index 761d10585..b427b458a 100644 --- a/src/ampform/helicity/naming.py +++ b/src/ampform/helicity/naming.py @@ -1,4 +1,5 @@ """Generate descriptions used in the `~ampform.helicity` formalism.""" + from __future__ import annotations import re diff --git a/src/ampform/io/__init__.py b/src/ampform/io/__init__.py index 5d71ca7fd..e4d7b37f3 100644 --- a/src/ampform/io/__init__.py +++ b/src/ampform/io/__init__.py @@ -12,6 +12,7 @@ >>> aslatex(3.4 - 2j) '3.4-2i' """ + from __future__ import annotations from collections import abc diff --git a/src/ampform/kinematics/__init__.py b/src/ampform/kinematics/__init__.py index 3ae4cddcd..b16089d44 100644 --- a/src/ampform/kinematics/__init__.py +++ b/src/ampform/kinematics/__init__.py @@ -5,6 +5,7 @@ import sympy as sp from ampform.kinematics import create_four_momentum_symbols """ + from __future__ import annotations import itertools @@ -39,7 +40,7 @@ class HelicityAdapter: def __init__( self, - transitions: (ReactionInfo | Iterable[Topology | StateTransition]), + transitions: ReactionInfo | Iterable[Topology | StateTransition], ) -> None: self.__topologies = _extract_topologies(transitions) for topology in self.__topologies: diff --git a/src/ampform/kinematics/angles.py b/src/ampform/kinematics/angles.py index e42026ebb..6cfa1eb92 100644 --- a/src/ampform/kinematics/angles.py +++ b/src/ampform/kinematics/angles.py @@ -1,4 +1,5 @@ """Angle computations for (boosted) :mod:`.lorentz` vectors.""" + from __future__ import annotations from typing import TYPE_CHECKING, Mapping @@ -138,9 +139,9 @@ def __recursive_helicity_angles( sub_momenta_ids = determine_attached_final_state(topology, state_id) if len(sub_momenta_ids) > 1: # add all of these momenta together -> defines new subsystem - four_momentum = ArraySum( - *[four_momenta[i] for i in sub_momenta_ids] - ) + four_momentum = ArraySum(*[ + four_momenta[i] for i in sub_momenta_ids + ]) # boost all of those momenta into this new subsystem phi_expr = Phi(four_momentum) @@ -257,14 +258,8 @@ def formulate_scattering_angle( sj = sp.Symbol(f"m_{__get_id_complement(sibling_id)}", nonnegative=True) ** 2 sk = sp.Symbol(f"m_{__get_id_complement(spectator_id)}", nonnegative=True) ** 2 theta = sp.acos( - ( - 2 * sk * (sj - mk**2 - mi**2) - - (sk + mi**2 - mj**2) * (m0**2 - sk - mk**2) - ) - / ( - sp.sqrt(Kallen(m0**2, mk**2, sk)) - * sp.sqrt(Kallen(sk, mi**2, mj**2)) - ) + (2 * sk * (sj - mk**2 - mi**2) - (sk + mi**2 - mj**2) * (m0**2 - sk - mk**2)) + / (sp.sqrt(Kallen(m0**2, mk**2, sk)) * sp.sqrt(Kallen(sk, mi**2, mj**2))) ) return symbol, theta @@ -296,10 +291,7 @@ def formulate_theta_hat_angle( (m0**2 + mi**2 - si) * (m0**2 + mj**2 - sj) - 2 * m0**2 * (sk - mi**2 - mj**2) ) - / ( - sp.sqrt(Kallen(m0**2, mj**2, sj)) - * sp.sqrt(Kallen(m0**2, si, mi**2)) - ) + / (sp.sqrt(Kallen(m0**2, mj**2, sj)) * sp.sqrt(Kallen(m0**2, si, mi**2))) ) return symbol, theta _, theta = formulate_theta_hat_angle( @@ -338,8 +330,7 @@ def formulate_zeta_angle( # noqa: C901, PLR0911 2 * m1**2 * (s2 - m0**2 - m2**2) + (m0**2 + m1**2 - s1) * (s3 - m1**2 - m2**2) ) / ( - sp.sqrt(Kallen(m0**2, m1**2, s1)) - * sp.sqrt(Kallen(s3, m1**2, m2**2)) + sp.sqrt(Kallen(m0**2, m1**2, s1)) * sp.sqrt(Kallen(s3, m1**2, m2**2)) ) return zeta_symbol, sp.acos(cos_zeta_expr) if (rotated_state, aligned_subsystem, reference_subsystem) == (1, 2, 1): @@ -347,8 +338,7 @@ def formulate_zeta_angle( # noqa: C901, PLR0911 2 * m1**2 * (s3 - m0**2 - m3**2) + (m0**2 + m1**2 - s1) * (s2 - m1**2 - m3**2) ) / ( - sp.sqrt(Kallen(m0**2, m1**2, s1)) - * sp.sqrt(Kallen(s2, m1**2, m3**2)) + sp.sqrt(Kallen(m0**2, m1**2, s1)) * sp.sqrt(Kallen(s2, m1**2, m3**2)) ) return zeta_symbol, sp.acos(cos_zeta_expr) if (rotated_state, aligned_subsystem, reference_subsystem) == (2, 2, 1): @@ -356,8 +346,7 @@ def formulate_zeta_angle( # noqa: C901, PLR0911 2 * m2**2 * (s3 - m0**2 - m3**2) + (m0**2 + m2**2 - s2) * (s1 - m2**2 - m3**2) ) / ( - sp.sqrt(Kallen(m0**2, m2**2, s2)) - * sp.sqrt(Kallen(s1, m2**2, m3**2)) + sp.sqrt(Kallen(m0**2, m2**2, s2)) * sp.sqrt(Kallen(s1, m2**2, m3**2)) ) return zeta_symbol, sp.acos(cos_zeta_expr) if (rotated_state, aligned_subsystem, reference_subsystem) == (2, 3, 2): @@ -365,8 +354,7 @@ def formulate_zeta_angle( # noqa: C901, PLR0911 2 * m2**2 * (s1 - m0**2 - m1**2) + (m0**2 + m2**2 - s2) * (s3 - m2**2 - m1**2) ) / ( - sp.sqrt(Kallen(m0**2, m2**2, s2)) - * sp.sqrt(Kallen(s3, m2**2, m1**2)) + sp.sqrt(Kallen(m0**2, m2**2, s2)) * sp.sqrt(Kallen(s3, m2**2, m1**2)) ) return zeta_symbol, sp.acos(cos_zeta_expr) if (rotated_state, aligned_subsystem, reference_subsystem) == (3, 3, 2): @@ -374,8 +362,7 @@ def formulate_zeta_angle( # noqa: C901, PLR0911 2 * m3**2 * (s1 - m0**2 - m1**2) + (m0**2 + m3**2 - s3) * (s2 - m3**2 - m1**2) ) / ( - sp.sqrt(Kallen(m0**2, m3**2, s3)) - * sp.sqrt(Kallen(s2, m3**2, m1**2)) + sp.sqrt(Kallen(m0**2, m3**2, s3)) * sp.sqrt(Kallen(s2, m3**2, m1**2)) ) return zeta_symbol, sp.acos(cos_zeta_expr) if (rotated_state, aligned_subsystem, reference_subsystem) == (3, 1, 3): @@ -383,8 +370,7 @@ def formulate_zeta_angle( # noqa: C901, PLR0911 2 * m3**2 * (s2 - m0**2 - m2**2) + (m0**2 + m3**2 - s3) * (s1 - m3**2 - m2**2) ) / ( - sp.sqrt(Kallen(m0**2, m3**2, s3)) - * sp.sqrt(Kallen(s1, m3**2, m2**2)) + sp.sqrt(Kallen(m0**2, m3**2, s3)) * sp.sqrt(Kallen(s1, m3**2, m2**2)) ) return zeta_symbol, sp.acos(cos_zeta_expr) if (rotated_state, aligned_subsystem, reference_subsystem) in { # Eq (A10) @@ -399,8 +385,7 @@ def formulate_zeta_angle( # noqa: C901, PLR0911 2 * mi**2 * (mj**2 + mk**2 - si) + (sj - mi**2 - mk**2) * (sk - mi**2 - mj**2) ) / ( - sp.sqrt(Kallen(sj, mk**2, mi**2)) - * sp.sqrt(Kallen(sk, mi**2, mj**2)) + sp.sqrt(Kallen(sj, mk**2, mi**2)) * sp.sqrt(Kallen(sk, mi**2, mj**2)) ) return zeta_symbol, sp.acos(cos_zeta_expr) if (rotated_state, aligned_subsystem, reference_subsystem) in { diff --git a/src/ampform/kinematics/lorentz.py b/src/ampform/kinematics/lorentz.py index d01c6fa7b..cd5b9cd72 100644 --- a/src/ampform/kinematics/lorentz.py +++ b/src/ampform/kinematics/lorentz.py @@ -1,4 +1,5 @@ """Symbolic implementations for Lorentz vectors and boosts.""" + from __future__ import annotations from typing import TYPE_CHECKING, Dict @@ -263,14 +264,12 @@ def _momentum(self) -> MinkowskiMetric: return self.args[0] # type: ignore[return-value] def as_explicit(self) -> sp.MutableDenseMatrix: - return sp.Matrix( - [ - [1, 0, 0, 0], - [0, -1, 0, 0], - [0, 0, -1, 0], - [0, 0, 0, -1], - ] - ) + return sp.Matrix([ + [1, 0, 0, 0], + [0, -1, 0, 0], + [0, 0, -1, 0], + [0, 0, 0, -1], + ]) def _latex(self, printer: LatexPrinter, *args) -> str: return R"\boldsymbol{\eta}" @@ -311,14 +310,12 @@ def __new__( def as_explicit(self) -> sp.MutableDenseMatrix: beta = self.args[0] gamma = 1 / ComplexSqrt(1 - beta**2) # type: ignore[operator] - return sp.Matrix( - [ - [gamma, 0, 0, -gamma * beta], - [0, 1, 0, 0], - [0, 0, 1, 0], - [-gamma * beta, 0, 0, gamma], - ] - ) + return sp.Matrix([ + [gamma, 0, 0, -gamma * beta], + [0, 1, 0, 0], + [0, 0, 1, 0], + [-gamma * beta, 0, 0, gamma], + ]) def evaluate(self) -> _BoostZMatrixImplementation: beta = self.args[0] @@ -380,29 +377,27 @@ def as_explicit(self) -> sp.MutableDenseMatrix: beta_y = FourMomentumY(momentum) / energy beta_z = FourMomentumZ(momentum) / energy g = 1 / sp.sqrt(1 - beta_sq) - return sp.Matrix( + return sp.Matrix([ + [g, -g * beta_x, -g * beta_y, -g * beta_z], [ - [g, -g * beta_x, -g * beta_y, -g * beta_z], - [ - -g * beta_x, - 1 + (g - 1) * beta_x**2 / beta_sq, - (g - 1) * beta_y * beta_x / beta_sq, - (g - 1) * beta_z * beta_x / beta_sq, - ], - [ - -g * beta_y, - (g - 1) * beta_x * beta_y / beta_sq, - 1 + (g - 1) * beta_y**2 / beta_sq, - (g - 1) * beta_z * beta_y / beta_sq, - ], - [ - -g * beta_z, - (g - 1) * beta_x * beta_z / beta_sq, - (g - 1) * beta_y * beta_z / beta_sq, - 1 + (g - 1) * beta_z**2 / beta_sq, - ], - ] - ) + -g * beta_x, + 1 + (g - 1) * beta_x**2 / beta_sq, + (g - 1) * beta_y * beta_x / beta_sq, + (g - 1) * beta_z * beta_x / beta_sq, + ], + [ + -g * beta_y, + (g - 1) * beta_x * beta_y / beta_sq, + 1 + (g - 1) * beta_y**2 / beta_sq, + (g - 1) * beta_z * beta_y / beta_sq, + ], + [ + -g * beta_z, + (g - 1) * beta_x * beta_z / beta_sq, + (g - 1) * beta_y * beta_z / beta_sq, + 1 + (g - 1) * beta_z**2 / beta_sq, + ], + ]) def evaluate(self) -> _BoostMatrixImplementation: momentum = self.args[0] @@ -498,14 +493,12 @@ def __new__( def as_explicit(self) -> sp.MutableDenseMatrix: angle = self.args[0] - return sp.Matrix( - [ - [1, 0, 0, 0], - [0, sp.cos(angle), 0, sp.sin(angle)], - [0, 0, 1, 0], - [0, -sp.sin(angle), 0, sp.cos(angle)], - ] - ) + return sp.Matrix([ + [1, 0, 0, 0], + [0, sp.cos(angle), 0, sp.sin(angle)], + [0, 0, 1, 0], + [0, -sp.sin(angle), 0, sp.cos(angle)], + ]) def evaluate(self) -> _RotationYMatrixImplementation: angle = self.args[0] @@ -571,14 +564,12 @@ def __new__( def as_explicit(self) -> sp.MutableDenseMatrix: angle = self.args[0] - return sp.Matrix( - [ - [1, 0, 0, 0], - [0, sp.cos(angle), -sp.sin(angle), 0], - [0, sp.sin(angle), sp.cos(angle), 0], - [0, 0, 0, 1], - ] - ) + return sp.Matrix([ + [1, 0, 0, 0], + [0, sp.cos(angle), -sp.sin(angle), 0], + [0, sp.sin(angle), sp.cos(angle), 0], + [0, 0, 0, 1], + ]) def evaluate(self) -> _RotationZMatrixImplementation: angle = self.args[0] diff --git a/src/ampform/kinematics/phasespace.py b/src/ampform/kinematics/phasespace.py index 293d9c979..f82567ae5 100644 --- a/src/ampform/kinematics/phasespace.py +++ b/src/ampform/kinematics/phasespace.py @@ -2,6 +2,7 @@ .. seealso:: :doc:`/usage/kinematics` """ + from __future__ import annotations import sympy as sp diff --git a/src/ampform/sympy/__init__.py b/src/ampform/sympy/__init__.py index 833ce656f..13923f5bc 100644 --- a/src/ampform/sympy/__init__.py +++ b/src/ampform/sympy/__init__.py @@ -1,4 +1,5 @@ """Tools that facilitate in building :mod:`sympy` expressions.""" + # cspell:ignore mhash from __future__ import annotations @@ -384,12 +385,10 @@ def free_symbols(self) -> set[sp.Basic]: def evaluate(self) -> sp.Expr: indices = {symbol: tuple(values) for symbol, values in self.indices} - return sp.Add( - *[ - self.expression.subs(zip(indices, combi)) - for combi in itertools.product(*indices.values()) - ] - ) + return sp.Add(*[ + self.expression.subs(zip(indices, combi)) + for combi in itertools.product(*indices.values()) + ]) def _latex(self, printer: LatexPrinter, *args) -> str: indices = dict(self.indices) diff --git a/src/ampform/sympy/_array_expressions.py b/src/ampform/sympy/_array_expressions.py index 6c03f9535..5a97224ea 100644 --- a/src/ampform/sympy/_array_expressions.py +++ b/src/ampform/sympy/_array_expressions.py @@ -3,6 +3,7 @@ This module can be removed once `sympy/sympy#22265 `_ is merged and released. """ + from __future__ import annotations import string diff --git a/src/ampform/sympy/math.py b/src/ampform/sympy/math.py index bf865c717..1d52a3f01 100644 --- a/src/ampform/sympy/math.py +++ b/src/ampform/sympy/math.py @@ -1,4 +1,5 @@ """A collection of basic math operations, used in `ampform.dynamics`.""" + # cspell:ignore Lambdifier from __future__ import annotations diff --git a/src/symplot/__init__.py b/src/symplot/__init__.py index 8cf500119..1135a80f4 100644 --- a/src/symplot/__init__.py +++ b/src/symplot/__init__.py @@ -10,6 +10,7 @@ :func:`substitute_indexed_symbols`, that are useful when visualizing `sympy` expressions. """ + from __future__ import annotations import inspect @@ -395,10 +396,8 @@ def substitute_indexed_symbols(expression: sp.Expr) -> sp.Expr: See :doc:`compwa-org:report/008` for more info. """ - return expression.xreplace( - { - s: _indexed_to_symbol(s) - for s in expression.free_symbols - if isinstance(s, sp.Indexed) - } - ) + return expression.xreplace({ + s: _indexed_to_symbol(s) + for s in expression.free_symbols + if isinstance(s, sp.Indexed) + }) diff --git a/tests/conftest.py b/tests/conftest.py index 0e80f896e..304808622 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -54,60 +54,52 @@ def amplitude_model(reaction: ReactionInfo) -> tuple[str, HelicityModel]: @pytest.fixture(scope="session") def data_sample() -> dict[int, np.ndarray]: return { - 0: np.array( # pi0 - [ - (1.35527, 0.514208, -0.184219, 1.23296), - (0.841933, 0.0727385, -0.0528868, 0.826163), - (0.550927, -0.162529, 0.29976, -0.411133), - (0.425195, 0.0486171, 0.151922, 0.370309), - (0.186869, -0.0555915, -0.100214, -0.0597338), - (1.26375, 0.238921, 0.266712, -1.20442), - (0.737698, 0.450724, -0.439515, -0.360076), - (0.965809, 0.552298, 0.440006, 0.644927), - (0.397113, -0.248155, -0.158587, -0.229673), - (1.38955, 1.33491, 0.358535, 0.0457548), - ] - ), - 1: np.array( # gamma - [ - (0.755744, -0.305812, 0.284, -0.630057), - (1.02861, 0.784483, 0.614347, -0.255334), - (0.356875, -0.20767, 0.272796, 0.0990739), - (0.70757, 0.404557, 0.510467, -0.276426), - (0.953902, 0.47713, 0.284575, -0.775431), - (0.220732, -0.204775, -0.0197981, 0.0799868), - (0.734602, 0.00590727, 0.709346, -0.190877), - (0.607787, 0.329157, -0.431973, 0.272873), - (0.626325, -0.201436, -0.534829, 0.256253), - (0.386432, -0.196357, 0.00211926, -0.33282), - ] - ), - 2: np.array( # pi0 - [ - (0.208274, -0.061663, -0.0211864, 0.144596), - (0.461193, -0.243319, -0.283044, -0.234866), - (1.03294, 0.82872, -0.0465425, -0.599834), - (0.752466, 0.263003, -0.089236, 0.686187), - (0.746588, 0.656892, -0.107848, 0.309898), - (0.692537, 0.521569, -0.0448683, 0.43283), - (0.865147, -0.517582, -0.676002, -0.0734335), - (1.35759, -0.975278, -0.0207817, -0.934467), - (0.852141, -0.41665, 0.237646, 0.691269), - (0.616162, -0.464203, -0.358114, 0.13307), - ] - ), - 3: np.array( # pi0 - [ - (0.777613, -0.146733, -0.0785946, -0.747499), - (0.765168, -0.613903, -0.278416, -0.335962), - (1.15616, -0.458522, -0.526014, 0.911894), - (1.21167, -0.716177, -0.573154, -0.780069), - (1.20954, -1.07843, -0.0765127, 0.525267), - (0.919879, -0.555715, -0.202046, 0.691605), - (0.759452, 0.0609506, 0.406171, 0.624387), - (0.165716, 0.0938229, 0.012748, 0.0166676), - (1.22132, 0.866241, 0.455769, -0.717849), - (0.704759, -0.674348, -0.0025409, 0.153994), - ] - ), + 0: np.array([ # pi0 + (1.35527, 0.514208, -0.184219, 1.23296), + (0.841933, 0.0727385, -0.0528868, 0.826163), + (0.550927, -0.162529, 0.29976, -0.411133), + (0.425195, 0.0486171, 0.151922, 0.370309), + (0.186869, -0.0555915, -0.100214, -0.0597338), + (1.26375, 0.238921, 0.266712, -1.20442), + (0.737698, 0.450724, -0.439515, -0.360076), + (0.965809, 0.552298, 0.440006, 0.644927), + (0.397113, -0.248155, -0.158587, -0.229673), + (1.38955, 1.33491, 0.358535, 0.0457548), + ]), + 1: np.array([ # gamma + (0.755744, -0.305812, 0.284, -0.630057), + (1.02861, 0.784483, 0.614347, -0.255334), + (0.356875, -0.20767, 0.272796, 0.0990739), + (0.70757, 0.404557, 0.510467, -0.276426), + (0.953902, 0.47713, 0.284575, -0.775431), + (0.220732, -0.204775, -0.0197981, 0.0799868), + (0.734602, 0.00590727, 0.709346, -0.190877), + (0.607787, 0.329157, -0.431973, 0.272873), + (0.626325, -0.201436, -0.534829, 0.256253), + (0.386432, -0.196357, 0.00211926, -0.33282), + ]), + 2: np.array([ # pi0 + (0.208274, -0.061663, -0.0211864, 0.144596), + (0.461193, -0.243319, -0.283044, -0.234866), + (1.03294, 0.82872, -0.0465425, -0.599834), + (0.752466, 0.263003, -0.089236, 0.686187), + (0.746588, 0.656892, -0.107848, 0.309898), + (0.692537, 0.521569, -0.0448683, 0.43283), + (0.865147, -0.517582, -0.676002, -0.0734335), + (1.35759, -0.975278, -0.0207817, -0.934467), + (0.852141, -0.41665, 0.237646, 0.691269), + (0.616162, -0.464203, -0.358114, 0.13307), + ]), + 3: np.array([ # pi0 + (0.777613, -0.146733, -0.0785946, -0.747499), + (0.765168, -0.613903, -0.278416, -0.335962), + (1.15616, -0.458522, -0.526014, 0.911894), + (1.21167, -0.716177, -0.573154, -0.780069), + (1.20954, -1.07843, -0.0765127, 0.525267), + (0.919879, -0.555715, -0.202046, 0.691605), + (0.759452, 0.0609506, 0.406171, 0.624387), + (0.165716, 0.0938229, 0.012748, 0.0166676), + (1.22132, 0.866241, 0.455769, -0.717849), + (0.704759, -0.674348, -0.0025409, 0.153994), + ]), } diff --git a/tests/helicity/test_helicity.py b/tests/helicity/test_helicity.py index 8128e7161..cf4229dd7 100644 --- a/tests/helicity/test_helicity.py +++ b/tests/helicity/test_helicity.py @@ -186,12 +186,10 @@ def test_rename_parameters(self, amplitude_model: tuple[str, HelicityModel]): assert {d1, d2} <= model.expression.free_symbols new_d = sp.Symbol("d", positive=True) - new_model = model.rename_symbols( - { - d1.name: new_d.name, - d2.name: new_d.name, - } - ) + new_model = model.rename_symbols({ + d1.name: new_d.name, + d2.name: new_d.name, + }) assert not {d1, d2} & new_model.expression.free_symbols assert not {d1, d2} & set(new_model.parameter_defaults) assert new_d in new_model.parameter_defaults diff --git a/tests/kinematics/test_angles.py b/tests/kinematics/test_angles.py index 7f5c03e98..792185c51 100644 --- a/tests/kinematics/test_angles.py +++ b/tests/kinematics/test_angles.py @@ -77,105 +77,93 @@ def test_numpy(self): [ ( "phi_0", - np.array( - [ - 2.79758, - 2.51292, - -1.07396, - -1.88051, - 1.06433, - -2.30129, - 2.36878, - -2.46888, - 0.568649, - -2.8792, - ] - ), + np.array([ + 2.79758, + 2.51292, + -1.07396, + -1.88051, + 1.06433, + -2.30129, + 2.36878, + -2.46888, + 0.568649, + -2.8792, + ]), ), ( "theta_0", - np.arccos( - [ - -0.914298, - -0.994127, - 0.769715, - -0.918418, - 0.462214, - 0.958535, - 0.496489, - -0.674376, - 0.614968, - -0.0330843, - ] - ), + np.arccos([ + -0.914298, + -0.994127, + 0.769715, + -0.918418, + 0.462214, + 0.958535, + 0.496489, + -0.674376, + 0.614968, + -0.0330843, + ]), ), ( "phi_1^123", - np.array( - [ - 1.04362, - 1.87349, - 0.160733, - -2.81088, - 2.84379, - 2.29128, - 2.24539, - -1.20272, - 0.615838, - 2.98067, - ] - ), + np.array([ + 1.04362, + 1.87349, + 0.160733, + -2.81088, + 2.84379, + 2.29128, + 2.24539, + -1.20272, + 0.615838, + 2.98067, + ]), ), ( "theta_1^123", - np.arccos( - [ - -0.772533, - 0.163659, - 0.556365, - 0.133251, - -0.0264361, - 0.227188, - -0.166924, - 0.652761, - 0.443122, - 0.503577, - ] - ), + np.arccos([ + -0.772533, + 0.163659, + 0.556365, + 0.133251, + -0.0264361, + 0.227188, + -0.166924, + 0.652761, + 0.443122, + 0.503577, + ]), ), ( "phi_2^23,123", - np.array( - [ # WARNING: subsystem solution (ComPWA) results in pi differences - -2.77203 + np.pi, - 1.45339 - np.pi, - -2.51096 + np.pi, - 2.71085 - np.pi, - -1.12706 + np.pi, - -3.01323 + np.pi, - 2.07305 - np.pi, - 0.502648 - np.pi, - -1.23689 + np.pi, - 1.7605 - np.pi, - ] - ), + np.array([ # WARNING: subsystem solution (ComPWA) results in pi differences + -2.77203 + np.pi, + 1.45339 - np.pi, + -2.51096 + np.pi, + 2.71085 - np.pi, + -1.12706 + np.pi, + -3.01323 + np.pi, + 2.07305 - np.pi, + 0.502648 - np.pi, + -1.23689 + np.pi, + 1.7605 - np.pi, + ]), ), ( "theta_2^23,123", - np.arccos( - [ - 0.460324, - -0.410464, - 0.248566, - -0.301959, - -0.522502, - 0.787267, - 0.488066, - 0.954167, - -0.553114, - 0.00256349, - ] - ), + np.arccos([ + 0.460324, + -0.410464, + 0.248566, + -0.301959, + -0.522502, + 0.787267, + 0.488066, + 0.954167, + -0.553114, + 0.00256349, + ]), ), ], ) @@ -275,37 +263,22 @@ def test_compute_wigner_rotation_matrix_numpy( def test_formulate_scattering_angle(): assert formulate_scattering_angle(2, 3)[1] == sp.acos( - ( - 2 * s1 * (-(m1**2) - m2**2 + s3) - - (m0**2 - m1**2 - s1) * (m2**2 - m3**2 + s1) - ) - / ( - sp.sqrt(Kallen(m0**2, m1**2, s1)) - * sp.sqrt(Kallen(s1, m2**2, m3**2)) - ) + (2 * s1 * (-(m1**2) - m2**2 + s3) - (m0**2 - m1**2 - s1) * (m2**2 - m3**2 + s1)) + / (sp.sqrt(Kallen(m0**2, m1**2, s1)) * sp.sqrt(Kallen(s1, m2**2, m3**2))) ) assert formulate_scattering_angle(3, 1)[1] == sp.acos( ( 2 * s2 * (-(m2**2) - m3**2 + s1) - (m0**2 - m2**2 - s2) * (-(m1**2) + m3**2 + s2) ) - / ( - sp.sqrt(Kallen(m0**2, m2**2, s2)) - * sp.sqrt(Kallen(s2, m3**2, m1**2)) - ) + / (sp.sqrt(Kallen(m0**2, m2**2, s2)) * sp.sqrt(Kallen(s2, m3**2, m1**2))) ) def test_formulate_theta_hat_angle(): assert formulate_theta_hat_angle(1, 2)[1] == sp.acos( - ( - (m0**2 + m1**2 - s1) * (m0**2 + m2**2 - s2) - - 2 * m0**2 * (s3 - m1**2 - m2**2) - ) - / ( - sp.sqrt(Kallen(m0**2, m2**2, s2)) - * sp.sqrt(Kallen(m0**2, s1, m1**2)) - ) + ((m0**2 + m1**2 - s1) * (m0**2 + m2**2 - s2) - 2 * m0**2 * (s3 - m1**2 - m2**2)) + / (sp.sqrt(Kallen(m0**2, m2**2, s2)) * sp.sqrt(Kallen(m0**2, s1, m1**2))) ) assert formulate_theta_hat_angle(1, 2)[1] == -formulate_theta_hat_angle(2, 1)[1] for i in [1, 2, 3]: diff --git a/tests/kinematics/test_lorentz.py b/tests/kinematics/test_lorentz.py index e07a7fc62..178ee610f 100644 --- a/tests/kinematics/test_lorentz.py +++ b/tests/kinematics/test_lorentz.py @@ -50,14 +50,12 @@ def test_boost_in_z_direction_reduces_to_z_boost(self): func = sp.lambdify(p, expr.doit(), cse=True) p_array = np.array([[5, 0, 0, 1]]) matrix = func(p_array)[0] - assert pytest.approx(matrix) == np.array( - [ - [1.02062073, 0, 0, -0.20412415], - [0, 1, 0, 0], - [0, 0, 1, 0], - [-0.20412415, 0, 0, 1.02062073], - ] - ) + assert pytest.approx(matrix) == np.array([ + [1.02062073, 0, 0, -0.20412415], + [0, 1, 0, 0], + [0, 0, 1, 0], + [-0.20412415, 0, 0, 1.02062073], + ]) beta = three_momentum_norm(p) / Energy(p) z_expr = BoostZMatrix(beta) @@ -337,14 +335,12 @@ def test_rotation_over_multiple_two_pi_is_identity(rotation): func = sp.lambdify(angle, expr.doit(), cse=True) angle_array = np.arange(-2, 4, 1) * 2 * np.pi rotation_matrices = func(angle_array) - identity = np.array( - [ - [1, 0, 0, 0], - [0, 1, 0, 0], - [0, 0, 1, 0], - [0, 0, 0, 1], - ] - ) + identity = np.array([ + [1, 0, 0, 0], + [0, 1, 0, 0], + [0, 0, 1, 0], + [0, 0, 0, 1], + ]) identity = np.tile(identity, reps=(len(angle_array), 1, 1)) assert pytest.approx(rotation_matrices) == identity diff --git a/tests/symplot/test_ipywidgets.py b/tests/symplot/test_ipywidgets.py index cf24ee8f2..8d93113b8 100644 --- a/tests/symplot/test_ipywidgets.py +++ b/tests/symplot/test_ipywidgets.py @@ -1,4 +1,5 @@ """Behavior tests of `ipywidgets`.""" + import os import pytest