From 4ecdda49c5b97462ef3dfe8f1497b2b244e0c506 Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Tue, 19 Apr 2022 18:17:45 +0200 Subject: [PATCH 1/3] fix: update links to AmpForm API --- .cspell.json | 1 + docs/report/000.ipynb | 2 +- docs/report/003.ipynb | 4 ++-- docs/report/004.ipynb | 2 +- docs/report/005.ipynb | 2 +- docs/report/009.ipynb | 2 +- 6 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.cspell.json b/.cspell.json index 6c38e44a..852d25d3 100644 --- a/.cspell.json +++ b/.cspell.json @@ -214,6 +214,7 @@ "pandoc", "pcolormesh", "pdg's", + "phasespace", "phsp", "pmatrix", "preorder", diff --git a/docs/report/000.ipynb b/docs/report/000.ipynb index 3f8df44a..2c11df3d 100644 --- a/docs/report/000.ipynb +++ b/docs/report/000.ipynb @@ -323,7 +323,7 @@ "source": [ "**There is a problem with this approach though**: once input data is complex, _all_ square roots in a larger expression (some amplitude model) compute imaginary solutions for negative values, while this is not always the desired behavior.\n", "\n", - "Take for instance the two square roots appearing in {class}`~ampform.dynamics.PhaseSpaceFactor` --- does the $\\sqrt{s}$ also have to be evaluatable for negative $s$?" + "Take for instance the two square roots appearing in {class}`~ampform.dynamics.phasespace.PhaseSpaceFactor` --- does the $\\sqrt{s}$ also have to be evaluatable for negative $s$?" ] }, { diff --git a/docs/report/003.ipynb b/docs/report/003.ipynb index c0d33e61..a17d92d3 100644 --- a/docs/report/003.ipynb +++ b/docs/report/003.ipynb @@ -407,7 +407,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "For comparison, we plot the Chew-Mandelstam function for $S$-waves next to AmpForm's {class}`~ampform.dynamics.PhaseSpaceFactorComplex`. Have a look at the resulting plots and compare to Figure 50.4 on {pdg-review}`2021; Resonances; p.12`." + "For comparison, we plot the Chew-Mandelstam function for $S$-waves next to AmpForm's {class}`~ampform.dynamics.phasespace.PhaseSpaceFactorComplex`. Have a look at the resulting plots and compare to Figure 50.4 on {pdg-review}`2021; Resonances; p.12`." ] }, { @@ -585,7 +585,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "For $\\rho_a$, we use AmpForm's {class}`~ampform.dynamics.PhaseSpaceFactor`:" + "For $\\rho_a$, we use AmpForm's {class}`~ampform.dynamics.phasespace.PhaseSpaceFactor`:" ] }, { diff --git a/docs/report/004.ipynb b/docs/report/004.ipynb index af962d95..f8e88fb7 100644 --- a/docs/report/004.ipynb +++ b/docs/report/004.ipynb @@ -377,7 +377,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Interactive reproduction of Figure 49.1 on {pdg-review}`2020; Resonances; p.2`. The formulas below come from a {func}`~ampform.dynamics.relativistic_breit_wigner_with_ff` with $L=0$. As phase space factor, we used the square root of {class}`~ampform.dynamics.BreakupMomentumSquared` instead of the default {class}`~ampform.dynamics.PhaseSpaceFactor`, because this introduces only one branch point in the $s$-plane (namely the one over the nominator)." + "Interactive reproduction of Figure 49.1 on {pdg-review}`2020; Resonances; p.2`. The formulas below come from a {func}`~ampform.dynamics.relativistic_breit_wigner_with_ff` with $L=0$. As phase space factor, we used the square root of {class}`~ampform.dynamics.phasespace.BreakupMomentumSquared` instead of the default {class}`~ampform.dynamics.phasespace.PhaseSpaceFactor`, because this introduces only one branch point in the $s$-plane (namely the one over the nominator)." ] }, { diff --git a/docs/report/005.ipynb b/docs/report/005.ipynb index f98d61dd..19a4b3e7 100644 --- a/docs/report/005.ipynb +++ b/docs/report/005.ipynb @@ -228,7 +228,7 @@ "\n", "with $\\boldsymbol{I}$ the identity operator. With this in mind, there is an important restriction that the $T$-operator needs to comply with: **unitarity**. This means that $\\boldsymbol{S}$ should conserve probability, namely $\\boldsymbol{S}^\\dagger\\boldsymbol{S} = \\boldsymbol{I}$.\n", "\n", - "### K-matrix\n", + "### K-matrix formalism\n", "\n", "Now there is a trick to ensure unitarity of $\\boldsymbol{S}$. We can express $\\boldsymbol{S}$ in terms of an operator $\\boldsymbol{K}$ by applying a [Cayley transformation](https://en.wikipedia.org/wiki/Cayley_transform):\n", "\n", diff --git a/docs/report/009.ipynb b/docs/report/009.ipynb index d460a7dc..2e2dfe66 100644 --- a/docs/report/009.ipynb +++ b/docs/report/009.ipynb @@ -425,7 +425,7 @@ "source": [ ":::{note}\n", "\n", - "In `PhaseSpaceFactor`, we used {class}`~ampform.dynamics.PhaseSpaceFactorComplex` instead of {class}`~ampform.dynamics.PhaseSpaceFactor`, meaning that we choose the _positive_ square root when values under the square root are negative. The only reason for doing this is, so that there is output in the figure under {ref}`report/009:Visualization`. The choice for which square root to choose has to do with analyticity (see {doc}`/report/004`) and choosing which Riemann sheet to connect to. This issue is ignored in this report.\n", + "In `PhaseSpaceFactor`, we used {class}`~ampform.dynamics.phasespace.PhaseSpaceFactorComplex` instead of {class}`~ampform.dynamics.phasespace.PhaseSpaceFactor`, meaning that we choose the _positive_ square root when values under the square root are negative. The only reason for doing this is, so that there is output in the figure under {ref}`report/009:Visualization`. The choice for which square root to choose has to do with analyticity (see {doc}`/report/004`) and choosing which Riemann sheet to connect to. This issue is ignored in this report.\n", "\n", ":::" ] From d8f7bd718e9d28662821dedccd33cc181d21d984 Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Tue, 19 Apr 2022 18:55:40 +0200 Subject: [PATCH 2/3] build: drop support for Python 3.6 --- .constraints/py3.6.txt | 202 ------------------------ .github/workflows/requirements-cron.yml | 1 - .github/workflows/requirements-pr.yml | 1 - .pre-commit-config.yaml | 4 +- pyproject.toml | 1 - setup.cfg | 12 +- 6 files changed, 6 insertions(+), 215 deletions(-) delete mode 100644 .constraints/py3.6.txt diff --git a/.constraints/py3.6.txt b/.constraints/py3.6.txt deleted file mode 100644 index 078a9733..00000000 --- a/.constraints/py3.6.txt +++ /dev/null @@ -1,202 +0,0 @@ -# -# This file is autogenerated by pip-compile with python 3.6 -# To update, run: -# -# pip-compile --extra=dev --no-annotate --output-file=.constraints/py3.6.txt --strip-extras setup.py -# -alabaster==0.7.12 -anyio==3.5.0 -appdirs==1.4.4 -aquirdturtle-collapsible-headings==3.1.0 -argon2-cffi==21.3.0 -argon2-cffi-bindings==21.2.0 -astroid==2.7.3 -async-generator==1.10 -attrs==21.4.0 -babel==2.9.1 -backcall==0.2.0 -beautifulsoup4==4.10.0 -black==21.7b0 ; python_version == "3.6.*" -bleach==4.1.0 -certifi==2021.10.8 -cffi==1.15.0 -cfgv==3.3.1 -charset-normalizer==2.0.12 -click==8.0.4 -colorama==0.4.4 -contextvars==2.4 -cycler==0.11.0 -dataclasses==0.8 -decorator==5.1.1 -defusedxml==0.7.1 -distlib==0.3.4 -docutils==0.16 -entrypoints==0.4 -execnet==1.9.0 -filelock==3.4.1 -flake8==4.0.1 -flake8-blind-except==0.2.1 -flake8-bugbear==22.3.23 -flake8-builtins==1.5.3 -flake8-comprehensions==3.7.0 -flake8-plugin-utils==1.3.2 -flake8-polyfill==1.0.2 -flake8-pytest-style==1.6.0 -flake8-rst-docstrings==0.2.5 -flake8-use-fstring==1.3 -future==0.18.2 -gitdb==4.0.9 -gitpython==3.1.18 -graphviz==0.19.1 -greenlet==1.1.2 -identify==2.4.4 -idna==3.3 -imagesize==1.3.0 -immutables==0.17 -importlib-metadata==4.2.0 -importlib-resources==3.0.0 -iniconfig==1.1.1 -ipykernel==5.5.6 -ipympl==0.8.8 -ipython==7.16.3 -ipython-genutils==0.2.0 -ipywidgets==7.7.0 -isort==5.10.1 -jedi==0.17.2 -jinja2==3.0.3 -json5==0.9.6 -jsonschema==3.2.0 -jupyter==1.0.0 -jupyter-cache==0.4.3 -jupyter-client==7.1.2 -jupyter-console==6.4.3 -jupyter-contrib-core==0.3.3 -jupyter-contrib-nbextensions==0.5.1 -jupyter-core==4.9.2 -jupyter-highlight-selected-word==0.2.0 -jupyter-latex-envs==1.4.6 -jupyter-nbextensions-configurator==0.4.1 -jupyter-server==1.13.1 -jupyter-server-mathjax==0.2.3 -jupyter-sphinx==0.3.2 -jupyterlab==3.2.9 -jupyterlab-code-formatter==1.4.10 -jupyterlab-pygments==0.1.2 -jupyterlab-server==2.10.3 -jupyterlab-widgets==1.1.0 -kiwisolver==1.3.1 -latexcodec==2.0.1 -lazy-object-proxy==1.7.1 -livereload==2.6.3 -lxml==4.8.0 -mando==0.6.4 -markdown==3.3.4 ; python_version < "3.8.0" -markdown-it-py==1.1.0 -markupsafe==2.0.1 -matplotlib==3.3.4 -mccabe==0.6.1 -mdit-py-plugins==0.2.8 -mistune==0.8.4 -mpl-interactions==0.20.0 ; python_version < "3.7" -mypy-extensions==0.4.3 -myst-nb==0.13.2 -myst-parser==0.15.2 -nbclassic==0.3.5 -nbclient==0.5.9 -nbconvert==6.0.7 -nbdime==3.1.1 -nbformat==5.1.3 -nbmake==1.2.1 -nest-asyncio==1.5.5 -nodeenv==1.6.0 -notebook==6.4.10 -numpy==1.19.5 -packaging==21.3 -pandocfilters==1.5.0 -parso==0.7.1 -pathspec==0.9.0 -pep517==0.12.0 -pep8-naming==0.12.1 -pexpect==4.8.0 -pickleshare==0.7.5 -pillow==8.4.0 -pip-tools==6.4.0 -platformdirs==2.4.0 -pluggy==1.0.0 -pre-commit==2.17.0 -prometheus-client==0.13.1 -prompt-toolkit==3.0.28 -ptyprocess==0.7.0 -py==1.11.0 -pybtex==0.24.0 -pybtex-docutils==1.0.1 -pycodestyle==2.8.0 -pycparser==2.21 -pydantic==1.9.0 -pydata-sphinx-theme==0.7.2 -pyflakes==2.4.0 -pygments==2.11.2 -pylint==2.10.2 ; python_version == "3.6.*" -pyparsing==3.0.7 -pyrsistent==0.18.0 -pytest==7.0.1 -pytest-forked==1.4.0 -pytest-xdist==2.5.0 -python-dateutil==2.8.2 -pytz==2022.1 -pyyaml==6.0 -pyzmq==22.3.0 -qtconsole==5.2.2 -qtpy==2.0.1 -radon==5.1.0 -regex==2022.3.15 -requests==2.27.1 -restructuredtext-lint==1.4.0 -rise==5.7.1 -send2trash==1.8.0 -six==1.16.0 -smmap==5.0.0 -sniffio==1.2.0 -snowballstemmer==2.2.0 -soupsieve==2.3.1 -sphinx==4.3.2 ; python_version < "3.8.0" -sphinx-autobuild==2021.3.14 -sphinx-book-theme==0.2.0 -sphinx-codeautolink==0.10.0 -sphinx-comments==0.0.3 -sphinx-copybutton==0.5.0 -sphinx-issues==3.0.1 -sphinx-panels==0.6.0 -sphinx-thebe==0.1.1 -sphinx-togglebutton==0.3.1 -sphinxcontrib-applehelp==1.0.2 -sphinxcontrib-bibtex==2.4.1 -sphinxcontrib-devhelp==1.0.2 -sphinxcontrib-hep-pdgref==0.1.4 -sphinxcontrib-htmlhelp==2.0.0 -sphinxcontrib-jsmath==1.0.1 -sphinxcontrib-qthelp==1.0.3 -sphinxcontrib-serializinghtml==1.1.5 -sqlalchemy==1.4.34 -terminado==0.12.1 -testpath==0.6.0 -toml==0.10.2 -tomli==1.2.3 -tornado==6.1 -tox==3.24.5 -traitlets==4.3.3 -typed-ast==1.4.3 -typing-extensions==4.1.1 -urllib3==1.26.9 -virtualenv==20.14.0 -wcwidth==0.2.5 -webencodings==0.5.1 -websocket-client==1.3.1 -wheel==0.37.1 -widgetsnbextension==3.6.0 -wrapt==1.12.1 -zipp==3.6.0 - -# The following packages are considered to be unsafe in a requirements file: -# pip -# setuptools diff --git a/.github/workflows/requirements-cron.yml b/.github/workflows/requirements-cron.yml index ed72a69b..30766dd4 100644 --- a/.github/workflows/requirements-cron.yml +++ b/.github/workflows/requirements-cron.yml @@ -13,7 +13,6 @@ jobs: fail-fast: false matrix: python-version: - - "3.6" - "3.7" - "3.8" - "3.9" diff --git a/.github/workflows/requirements-pr.yml b/.github/workflows/requirements-pr.yml index ba72e003..afc208dd 100644 --- a/.github/workflows/requirements-pr.yml +++ b/.github/workflows/requirements-pr.yml @@ -36,7 +36,6 @@ jobs: fail-fast: false matrix: python-version: - - "3.6" - "3.7" - "3.8" - "3.9" diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 084251b0..bff2d215 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -102,7 +102,7 @@ repos: - id: nbqa-isort - id: nbqa-pyupgrade args: - - --py36-plus + - --py37-plus - repo: https://github.com/kynan/nbstripout rev: 0.5.0 @@ -145,7 +145,7 @@ repos: hooks: - id: pyupgrade args: - - --py36-plus + - --py37-plus # The following tools have to be install locally, because they can also be # used by code editors (e.g. linting and format-on-save). diff --git a/pyproject.toml b/pyproject.toml index 2f6e52fb..1ec3daac 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -26,7 +26,6 @@ include = '\.pyi?$' line-length = 79 preview = true target-version = [ - "py36", "py37", "py38", "py39", diff --git a/setup.cfg b/setup.cfg index b0835fbd..e20df4e4 100644 --- a/setup.cfg +++ b/setup.cfg @@ -20,7 +20,6 @@ classifiers = Natural Language :: English Operating System :: OS Independent Programming Language :: Python - Programming Language :: Python :: 3.6 Programming Language :: Python :: 3.7 Programming Language :: Python :: 3.8 Programming Language :: Python :: 3.9 @@ -28,13 +27,12 @@ classifiers = Topic :: Scientific/Engineering :: Physics [options] -python_requires = >=3.6, <3.10 +python_requires = >=3.7, <3.10 install_requires = graphviz ipympl matplotlib mpl-interactions - mpl-interactions <0.20.1; python_version <'3.7' # https://github.com/ComPWA/compwa-org/runs/4998906234 setup_requires = setuptools_scm @@ -61,8 +59,7 @@ test = pytest pytest-xdist format = - black; python_version >="3.7.0" - black <21.8*; python_version=="3.6.*" # https://github.com/ComPWA/compwa-org/runs/4398753864 + black isort flake8 = flake8 >=4 # extend-select @@ -78,8 +75,7 @@ flake8 = pep8-naming lint = %(flake8)s - pylint; python_version >="3.7.0" - pylint <2.11; python_version=="3.6.*" # https://github.com/ComPWA/compwa-org/runs/4398753864 + pylint radon sty = %(format)s @@ -94,7 +90,7 @@ dev = jupyter-nbextensions-configurator jupyterlab >=3.0.0 jupyterlab-code-formatter - jupyterlab-myst; python_version >="3.7.0" + jupyterlab-myst pip-tools >=6.1.0 # for extras_require sphinx-autobuild tox >=1.9 # for skip_install, use_develop From bce8267d41aecca450265dd74a323caff8ff0c66 Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Tue, 19 Apr 2022 19:07:32 +0200 Subject: [PATCH 3/3] style: rewrite type hints with PEP563 https://peps.python.org/pep-0563 --- .pre-commit-config.yaml | 2 ++ docs/adr/001/operators.ipynb | 10 ++++---- docs/adr/001/sympy.ipynb | 6 ++--- docs/adr/002/composition.ipynb | 8 +++--- docs/adr/002/expr.ipynb | 30 +++++++++++----------- docs/adr/002/helpers.py | 5 ++-- docs/report/001.ipynb | 9 +++---- docs/report/002.ipynb | 8 +++--- docs/report/005.ipynb | 5 ++-- docs/report/009.ipynb | 17 ++++++------ docs/report/010.ipynb | 23 +++++++++-------- docs/report/011.ipynb | 47 +++++++++++++++++----------------- docs/report/014.ipynb | 27 +++++++++---------- setup.cfg | 1 + 14 files changed, 102 insertions(+), 96 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index bff2d215..2994d4cf 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -99,6 +99,8 @@ repos: additional_dependencies: - black>=22.1.0 - id: nbqa-flake8 + additional_dependencies: + - flake8-future-annotations - id: nbqa-isort - id: nbqa-pyupgrade args: diff --git a/docs/adr/001/operators.ipynb b/docs/adr/001/operators.ipynb index 4c4e4efc..80571352 100644 --- a/docs/adr/001/operators.ipynb +++ b/docs/adr/001/operators.ipynb @@ -451,7 +451,7 @@ "\n", "Here's a rough sketch with `tensorwaves` in mind.\n", "```python\n", - "from typing import Dict, Generator, List\n", + "from typing import Generator\n", "\n", "import attr\n", "\n", @@ -483,10 +483,10 @@ "\n", " def __init__(self, model: AmplitudeModel) -> None:\n", " self.__model: AmplitudeModel\n", - " self.__parameter_couplings: Dict[str, str]\n", + " self.__parameter_couplings: dict[str, str]\n", "\n", " @property\n", - " def parameters(self) -> List[FitParameter]:\n", + " def parameters(self) -> list[FitParameter]:\n", " initial_parameters = list(__yield_parameter(self.__model))\n", " self.__apply_couplings()\n", " return self.__convert(initial_parameters)\n", @@ -494,7 +494,7 @@ " def couple_parameters(self, parameter1: str, parameter2: str) -> None:\n", " pass\n", "\n", - " def __convert(self, params: List[InitialParameter]) -> List[FitParameter]:\n", + " def __convert(self, params: list[InitialParameter]) -> list[FitParameter]:\n", " pass\n", "\n", "\n", @@ -530,7 +530,7 @@ "builder = IntensityBuilder(kinematics)\n", "\n", "intensity = builder.create(amp_model) # this would call amp_model.parameters\n", - "parameters: Dict[str, float] = intensity.parameters\n", + "parameters: dict[str, float] = intensity.parameters\n", "# PROBLEM?: fix status is lost at this point\n", "\n", "data_sample = generate_data(...)\n", diff --git a/docs/adr/001/sympy.ipynb b/docs/adr/001/sympy.ipynb index ed19d654..fc866195 100644 --- a/docs/adr/001/sympy.ipynb +++ b/docs/adr/001/sympy.ipynb @@ -80,7 +80,7 @@ }, "outputs": [], "source": [ - "from typing import Dict\n", + "from __future__ import annotations\n", "\n", "import attr\n", "import sympy as sp\n", @@ -88,8 +88,8 @@ "\n", "@attr.s\n", "class AmplitudeModel:\n", - " initial_values: Dict[sp.Symbol, float] = attr.ib(default={})\n", - " dynamics: Dict[sp.Symbol, sp.Function] = attr.ib(default={})\n", + " initial_values: dict[sp.Symbol, float] = attr.ib(default={})\n", + " dynamics: dict[sp.Symbol, sp.Function] = attr.ib(default={})\n", " intensity: sp.Expr = attr.ib(default=None)" ] }, diff --git a/docs/adr/002/composition.ipynb b/docs/adr/002/composition.ipynb index 60bf9e0e..b3da9cb3 100644 --- a/docs/adr/002/composition.ipynb +++ b/docs/adr/002/composition.ipynb @@ -62,7 +62,7 @@ }, "outputs": [], "source": [ - "from typing import Tuple\n", + "from __future__ import annotations\n", "\n", "import attr\n", "import sympy as sp\n", @@ -94,8 +94,8 @@ "source": [ "@attr.s(frozen=True)\n", "class DynamicsExpression:\n", - " variables: Tuple[sp.Symbol, ...] = attr.ib()\n", - " parameters: Tuple[sp.Symbol, ...] = attr.ib()\n", + " variables: tuple[sp.Symbol, ...] = attr.ib()\n", + " parameters: tuple[sp.Symbol, ...] = attr.ib()\n", " expression: sp.Expr = attr.ib()\n", "\n", " def substitute(self) -> sp.Expr:\n", @@ -2020,7 +2020,7 @@ "outputs": [], "source": [ "def expression(\n", - " variables: Tuple[sp.Symbol, ...], parameters: Tuple[sp.Symbol, ...]\n", + " variables: tuple[sp.Symbol, ...], parameters: tuple[sp.Symbol, ...]\n", ") -> sp.Expr:\n", " pass" ] diff --git a/docs/adr/002/expr.ipynb b/docs/adr/002/expr.ipynb index 658da29e..e46bfdec 100644 --- a/docs/adr/002/expr.ipynb +++ b/docs/adr/002/expr.ipynb @@ -63,7 +63,7 @@ "outputs": [], "source": [ "from abc import abstractmethod\n", - "from typing import Any, Callable, Set, Type\n", + "from typing import Callable\n", "\n", "import sympy as sp\n", "from helpers import (\n", @@ -94,11 +94,11 @@ "class DynamicsExpr(sp.Expr):\n", " @classmethod\n", " @abstractmethod\n", - " def __new__(cls, *args: sp.Symbol, **hints: Any) -> sp.Expr:\n", + " def __new__(cls, *args: sp.Symbol, **hints) -> sp.Expr:\n", " pass\n", "\n", " @abstractmethod\n", - " def doit(self, **hints: Any) -> sp.Expr:\n", + " def doit(self, **hints) -> sp.Expr:\n", " pass\n", "\n", " @abstractmethod\n", @@ -125,7 +125,7 @@ "outputs": [], "source": [ "class RelativisticBreitWigner(DynamicsExpr):\n", - " def __new__(cls, *args: sp.Symbol, **hints: Any) -> sp.Expr:\n", + " def __new__(cls, *args: sp.Symbol, **hints) -> sp.Expr:\n", " if len(args) != 3:\n", " raise ValueError(f\"3 parameters expected, got {len(args)}\")\n", " args = sp.sympify(args)\n", @@ -147,14 +147,14 @@ " return self.args[2]\n", "\n", " @property\n", - " def variables(self) -> Set[sp.Symbol]:\n", + " def variables(self) -> set[sp.Symbol]:\n", " return {self.mass}\n", "\n", " @property\n", - " def parameters(self) -> Set[sp.Symbol]:\n", + " def parameters(self) -> set[sp.Symbol]:\n", " return {self.mass0, self.gamma0}\n", "\n", - " def doit(self, **hints: Any) -> sp.Expr:\n", + " def doit(self, **hints) -> sp.Expr:\n", " return RelativisticBreitWigner(*self.args, **hints, evaluate=True)\n", "\n", " def evaluate(self) -> sp.Expr:\n", @@ -195,7 +195,7 @@ "outputs": [], "source": [ "class RelativisticBreitWignerWithFF(DynamicsExpr):\n", - " def __new__(cls, *args: sp.Symbol, **hints: Any) -> sp.Expr:\n", + " def __new__(cls, *args: sp.Symbol, **hints) -> sp.Expr:\n", " if len(args) != 7:\n", " raise ValueError(f\"7 parameters expected, got {len(args)}\")\n", " args = sp.sympify(args)\n", @@ -204,7 +204,7 @@ " return sp.Expr.__new__(cls, *args).evaluate() # type: ignore # pylint: disable=no-member\n", " return sp.Expr.__new__(cls, *args)\n", "\n", - " def doit(self, **hints: Any) -> sp.Expr:\n", + " def doit(self, **hints) -> sp.Expr:\n", " return RelativisticBreitWignerWithFF(\n", " *self.args, **hints, evaluate=True\n", " )\n", @@ -1362,9 +1362,9 @@ "source": [ "def dynamics_expression(\n", " n_args: int,\n", - ") -> Callable[[type], Type[DynamicsExpr]]:\n", - " def decorator(decorated_class: type) -> Type[DynamicsExpr]:\n", - " def __new__(cls, *args: sp.Symbol, **hints: Any) -> sp.Expr:\n", + ") -> Callable[[type], type[DynamicsExpr]]:\n", + " def decorator(decorated_class: type) -> type[DynamicsExpr]:\n", + " def __new__(cls, *args: sp.Symbol, **hints) -> sp.Expr:\n", " if len(args) != n_args:\n", " raise ValueError(\n", " f\"{n_args} parameters expected, got {len(args)}\"\n", @@ -1375,7 +1375,7 @@ " return sp.Expr.__new__(cls, *args).evaluate()\n", " return sp.Expr.__new__(cls, *args)\n", "\n", - " def doit(self, **hints: Any) -> sp.Expr:\n", + " def doit(self, **hints) -> sp.Expr:\n", " return decorated_class(*self.args, **hints, evaluate=True)\n", "\n", " decorated_class.__new__ = __new__\n", @@ -1413,11 +1413,11 @@ " return self.args[2]\n", "\n", " @property\n", - " def variables(self) -> Set[sp.Symbol]:\n", + " def variables(self) -> set[sp.Symbol]:\n", " return {self.mass}\n", "\n", " @property\n", - " def parameters(self) -> Set[sp.Symbol]:\n", + " def parameters(self) -> set[sp.Symbol]:\n", " return {self.mu, self.sigma}\n", "\n", " def evaluate(self) -> sp.Expr:\n", diff --git a/docs/adr/002/helpers.py b/docs/adr/002/helpers.py index 0b19b26e..d342842f 100644 --- a/docs/adr/002/helpers.py +++ b/docs/adr/002/helpers.py @@ -1,6 +1,5 @@ # pylint: disable=import-error - -from typing import List +from __future__ import annotations import sympy as sp # pyright: reportMissingImports=false @@ -57,6 +56,6 @@ def two_body_momentum_squared( def determine_attached_final_state( # pylint: disable=unused-argument graph: StateTransitionGraph, edge_id: int, -) -> List[int]: +) -> list[int]: mock = [3, 4] return mock diff --git a/docs/report/001.ipynb b/docs/report/001.ipynb index fac0d12a..74fec3d2 100644 --- a/docs/report/001.ipynb +++ b/docs/report/001.ipynb @@ -102,7 +102,6 @@ "outputs": [], "source": [ "import inspect\n", - "from typing import Any\n", "\n", "import jax\n", "import jax.numpy as jnp\n", @@ -135,7 +134,7 @@ "\n", "\n", "class ComplexSqrt(sp.Expr):\n", - " def __new__(cls, x, *args: Any, **kwargs: Any):\n", + " def __new__(cls, x, *args, **kwargs):\n", " x = sp.sympify(x)\n", " expr = sp.Expr.__new__(cls, x, *args, **kwargs)\n", " if hasattr(x, \"free_symbols\") and not x.free_symbols:\n", @@ -151,16 +150,16 @@ " (sp.sqrt(x), True),\n", " )\n", "\n", - " def _latex(self, printer: Printer, *args: Any) -> str:\n", + " def _latex(self, printer: Printer, *args) -> str:\n", " x = printer._print(self.args[0])\n", " return Rf\"\\sqrt[\\mathrm{{c}}]{{{x}}}\"\n", "\n", - " def _numpycode(self, printer: Printer, *args: Any) -> str:\n", + " def _numpycode(self, printer: Printer, *args) -> str:\n", " printer.module_imports[\"numpy.lib\"].add(\"scimath\")\n", " x = printer._print(self.args[0])\n", " return f\"scimath.sqrt({x})\"\n", "\n", - " def _pythoncode(self, printer: Printer, *args: Any) -> str:\n", + " def _pythoncode(self, printer: Printer, *args) -> str:\n", " printer.module_imports[\"cmath\"].add(\"sqrt as csqrt\")\n", " x = printer._print(self.args[0])\n", " return f\"csqrt({x})\"" diff --git a/docs/report/002.ipynb b/docs/report/002.ipynb index 0d2cb5fd..818007eb 100644 --- a/docs/report/002.ipynb +++ b/docs/report/002.ipynb @@ -103,11 +103,13 @@ }, "outputs": [], "source": [ + "from __future__ import annotations\n", + "\n", "import inspect\n", "import logging\n", "import timeit\n", "import warnings\n", - "from typing import Callable, Dict, Generator, Optional, Sequence, Tuple\n", + "from typing import Callable, Generator, Sequence\n", "\n", "import ampform\n", "import graphviz\n", @@ -1535,7 +1537,7 @@ " expression: sp.Expr,\n", " max_complexity: int,\n", " min_complexity: int = 0,\n", - ") -> Tuple[sp.Expr, Dict[sp.Symbol, sp.Expr]]:\n", + ") -> tuple[sp.Expr, dict[sp.Symbol, sp.Expr]]:\n", " i = 0\n", " symbol_mapping = {}\n", "\n", @@ -1664,7 +1666,7 @@ "def optimized_lambdify(\n", " args: Sequence[sp.Symbol],\n", " expr: sp.Expr,\n", - " modules: Optional[str] = None,\n", + " modules: str | None = None,\n", " min_complexity: int = 0,\n", " max_complexity: int = 100,\n", ") -> Callable:\n", diff --git a/docs/report/005.ipynb b/docs/report/005.ipynb index 19a4b3e7..3fe5937d 100644 --- a/docs/report/005.ipynb +++ b/docs/report/005.ipynb @@ -118,9 +118,10 @@ }, "outputs": [], "source": [ + "from __future__ import annotations\n", + "\n", "import os\n", "import warnings\n", - "from typing import Union\n", "\n", "import graphviz\n", "import matplotlib.pyplot as plt\n", @@ -338,7 +339,7 @@ " gamma: sp.IndexedBase,\n", " i: int,\n", " j: int,\n", - " n_resonances: Union[int, sp.Symbol],\n", + " n_resonances: int | sp.Symbol,\n", ") -> sp.Expr:\n", " g_i = gamma[R, i] * sp.sqrt(M[R] * Gamma[R])\n", " g_j = gamma[R, j] * sp.sqrt(M[R] * Gamma[R])\n", diff --git a/docs/report/009.ipynb b/docs/report/009.ipynb index 2e2dfe66..39576ae1 100644 --- a/docs/report/009.ipynb +++ b/docs/report/009.ipynb @@ -180,10 +180,11 @@ }, "outputs": [], "source": [ + "from __future__ import annotations\n", + "\n", "import os\n", "import re\n", "import warnings\n", - "from typing import Union\n", "\n", "import matplotlib.pyplot as plt\n", "import mpl_interactions.ipyplot as iplt\n", @@ -251,7 +252,7 @@ " m_b: sp.Symbol,\n", " i: int,\n", " **hints,\n", - " ) -> \"PhaseSpaceFactor\":\n", + " ) -> PhaseSpaceFactor:\n", " return create_expression(cls, s, m_a, m_b, i, **hints)\n", "\n", " def evaluate(self) -> sp.Expr:\n", @@ -276,10 +277,10 @@ " m_a: sp.IndexedBase,\n", " m_b: sp.IndexedBase,\n", " angular_momentum: int,\n", - " R: Union[int, sp.Symbol],\n", + " R: int | sp.Symbol,\n", " i: int,\n", " **hints,\n", - " ) -> \"CoupledWidth\":\n", + " ) -> CoupledWidth:\n", " return create_expression(\n", " cls, s, mass0, gamma0, m_a, m_b, angular_momentum, R, i, **hints\n", " )\n", @@ -463,8 +464,8 @@ " gamma: sp.IndexedBase,\n", " i: int,\n", " j: int,\n", - " n_resonances: Union[int, sp.Symbol],\n", - " angular_momentum: Union[int, sp.Symbol] = 0,\n", + " n_resonances: int | sp.Symbol,\n", + " angular_momentum: int | sp.Symbol = 0,\n", ") -> sp.Expr:\n", " def residue_function(i):\n", " return gamma[R, i] * sp.sqrt(\n", @@ -481,7 +482,7 @@ "def relativistic_k_matrix(\n", " n_resonances: int,\n", " n_channels: int,\n", - " angular_momentum: Union[int, sp.Symbol] = 0,\n", + " angular_momentum: int | sp.Symbol = 0,\n", ") -> sp.Matrix:\n", " # Define symbols\n", " m = sp.Symbol(\"m\", real=True)\n", @@ -699,7 +700,7 @@ "def plot_relativistic_k_matrix(\n", " n_channels: int,\n", " n_resonances: int,\n", - " angular_momentum: Union[int, sp.Symbol] = 0,\n", + " angular_momentum: int | sp.Symbol = 0,\n", " title: str = \"\",\n", ") -> None:\n", " # Convert to Symbol: symplot cannot handle IndexedBase\n", diff --git a/docs/report/010.ipynb b/docs/report/010.ipynb index b5acbeca..7e00187a 100644 --- a/docs/report/010.ipynb +++ b/docs/report/010.ipynb @@ -119,10 +119,11 @@ }, "outputs": [], "source": [ + "from __future__ import annotations\n", + "\n", "import os\n", "import re\n", "import warnings\n", - "from typing import Union\n", "\n", "import matplotlib.pyplot as plt\n", "import mpl_interactions.ipyplot as iplt\n", @@ -240,7 +241,7 @@ " m_b: sp.Symbol,\n", " i: int,\n", " **hints,\n", - " ) -> \"PhaseSpaceFactor\":\n", + " ) -> PhaseSpaceFactor:\n", " return create_expression(cls, s, m_a, m_b, i, **hints)\n", "\n", " def evaluate(self) -> sp.Expr:\n", @@ -265,10 +266,10 @@ " m_a: sp.IndexedBase,\n", " m_b: sp.IndexedBase,\n", " angular_momentum: int,\n", - " R: Union[int, sp.Symbol],\n", + " R: int | sp.Symbol,\n", " i: int,\n", " **hints,\n", - " ) -> \"CoupledWidth\":\n", + " ) -> CoupledWidth:\n", " return create_expression(\n", " cls, s, mass0, gamma0, m_a, m_b, angular_momentum, R, i, **hints\n", " )\n", @@ -318,10 +319,10 @@ " beta: sp.IndexedBase,\n", " m_a: sp.IndexedBase,\n", " m_b: sp.IndexedBase,\n", - " R: Union[int, sp.Symbol],\n", + " R: int | sp.Symbol,\n", " i: int,\n", - " n_resonances: Union[int, sp.Symbol],\n", - " angular_momentum: Union[int, sp.Symbol] = 0,\n", + " n_resonances: int | sp.Symbol,\n", + " angular_momentum: int | sp.Symbol = 0,\n", ") -> sp.Expr:\n", " q_squared = breakup_momentum_squared(m**2, m_a[i], m_b[i])\n", " ff2 = BlattWeisskopfSquared(z=q_squared, angular_momentum=angular_momentum)\n", @@ -341,8 +342,8 @@ " R: sp.IndexedBase,\n", " i: int,\n", " j: int,\n", - " n_resonances: Union[int, sp.Symbol],\n", - " angular_momentum: Union[int, sp.Symbol] = 0,\n", + " n_resonances: int | sp.Symbol,\n", + " angular_momentum: int | sp.Symbol = 0,\n", ") -> sp.Expr:\n", " def residue_function(i):\n", " return gamma[R, i] * sp.sqrt(\n", @@ -359,7 +360,7 @@ "def f_vector(\n", " n_resonances: int,\n", " n_channels: int,\n", - " angular_momentum: Union[int, sp.Symbol] = 0,\n", + " angular_momentum: int | sp.Symbol = 0,\n", ") -> sp.Matrix:\n", " # Define symbols\n", " R = sp.Symbol(\"R\")\n", @@ -484,7 +485,7 @@ "def plot_f_vector(\n", " n_channels: int,\n", " n_resonances: int,\n", - " angular_momentum: Union[int, sp.Symbol] = 0,\n", + " angular_momentum: int | sp.Symbol = 0,\n", " title: str = \"\",\n", ") -> None:\n", " # Convert to Symbol: symplot cannot handle\n", diff --git a/docs/report/011.ipynb b/docs/report/011.ipynb index 8a1b7179..cddb5b29 100644 --- a/docs/report/011.ipynb +++ b/docs/report/011.ipynb @@ -110,8 +110,9 @@ }, "outputs": [], "source": [ + "from __future__ import annotations\n", + "\n", "import inspect\n", - "from typing import Any, Dict, Optional\n", "\n", "import black\n", "import graphviz\n", @@ -401,7 +402,7 @@ "outputs": [], "source": [ "class BoostZ(UnevaluatedExpression):\n", - " def __new__(cls, beta: sp.Symbol, **hints: Any) -> \"BoostZ\":\n", + " def __new__(cls, beta: sp.Symbol, **hints) -> BoostZ:\n", " return create_expression(cls, beta, **hints)\n", "\n", " def as_explicit(self) -> sp.Expr:\n", @@ -430,7 +431,7 @@ "outputs": [], "source": [ "class RotationY(UnevaluatedExpression):\n", - " def __new__(cls, angle: sp.Symbol, **hints: Any) -> \"RotationY\":\n", + " def __new__(cls, angle: sp.Symbol, **hints) -> RotationY:\n", " return create_expression(cls, angle, **hints)\n", "\n", " def as_explicit(self) -> sp.Expr:\n", @@ -464,7 +465,7 @@ "outputs": [], "source": [ "class RotationZ(UnevaluatedExpression):\n", - " def __new__(cls, angle: sp.Symbol, **hints: Any) -> \"RotationZ\":\n", + " def __new__(cls, angle: sp.Symbol, **hints) -> RotationZ:\n", " return create_expression(cls, angle, **hints)\n", "\n", " def as_explicit(self) -> sp.Expr:\n", @@ -509,7 +510,7 @@ "outputs": [], "source": [ "class ArrayMultiplication(sp.Expr):\n", - " def __new__(cls, *tensors: sp.Symbol, **hints: Any):\n", + " def __new__(cls, *tensors: sp.Symbol, **hints):\n", " return create_expression(cls, *tensors, **hints)\n", "\n", " def _latex(self, printer, *args) -> str:\n", @@ -645,7 +646,7 @@ }, "outputs": [], "source": [ - "def print_as_numpy(self, printer: Printer, *args: Any) -> str:\n", + "def print_as_numpy(self, printer: Printer, *args) -> str:\n", " def multiply(matrix, vector):\n", " return (\n", " 'einsum(\"ij...,j...\",'\n", @@ -1029,7 +1030,7 @@ "class FourMomentumX(UnevaluatedExpression):\n", " momentum: ArraySymbol = property(lambda self: self.args[0])\n", "\n", - " def __new__(cls, momentum: ArraySymbol, **hints: Any) -> \"FourMomentumX\":\n", + " def __new__(cls, momentum: ArraySymbol, **hints) -> FourMomentumX:\n", " return create_expression(cls, momentum, **hints)\n", "\n", " def evaluate(self) -> ArraySlice:\n", @@ -1044,7 +1045,7 @@ "class FourMomentumY(UnevaluatedExpression):\n", " momentum: ArraySymbol = property(lambda self: self.args[0])\n", "\n", - " def __new__(cls, momentum: ArraySymbol, **hints: Any) -> \"FourMomentumY\":\n", + " def __new__(cls, momentum: ArraySymbol, **hints) -> FourMomentumY:\n", " return create_expression(cls, momentum, **hints)\n", "\n", " def evaluate(self) -> ArraySlice:\n", @@ -1059,7 +1060,7 @@ "class FourMomentumZ(UnevaluatedExpression):\n", " momentum: ArraySymbol = property(lambda self: self.args[0])\n", "\n", - " def __new__(cls, momentum: ArraySymbol, **hints: Any) -> \"FourMomentumZ\":\n", + " def __new__(cls, momentum: ArraySymbol, **hints) -> FourMomentumZ:\n", " return create_expression(cls, momentum, **hints)\n", "\n", " def evaluate(self) -> ArraySlice:\n", @@ -1074,7 +1075,7 @@ "class Energy(UnevaluatedExpression):\n", " momentum: ArraySymbol = property(lambda self: self.args[0])\n", "\n", - " def __new__(cls, momentum: ArraySymbol, **hints: Any) -> \"Energy\":\n", + " def __new__(cls, momentum: ArraySymbol, **hints) -> Energy:\n", " return create_expression(cls, momentum, **hints)\n", "\n", " def evaluate(self) -> ArraySlice:\n", @@ -1089,7 +1090,7 @@ "class Phi(UnevaluatedExpression):\n", " momentum: ArraySymbol = property(lambda self: self.args[0])\n", "\n", - " def __new__(cls, momentum: ArraySymbol, **hints: Any) -> \"Phi\":\n", + " def __new__(cls, momentum: ArraySymbol, **hints) -> Phi:\n", " return create_expression(cls, momentum, **hints)\n", "\n", " def evaluate(self) -> sp.Expr:\n", @@ -1391,11 +1392,11 @@ "source": [ "class ArrayAxisSum(sp.Expr):\n", " array: ArraySymbol = property(lambda self: self.args[0])\n", - " axis: Optional[int] = property(lambda self: self.args[1])\n", + " axis: int | None = property(lambda self: self.args[1])\n", "\n", " def __new__(\n", - " cls, array: ArraySymbol, axis: Optional[int] = None, **hints: Any\n", - " ) -> \"ArrayAxisSum\":\n", + " cls, array: ArraySymbol, axis: int | None = None, **hints\n", + " ) -> ArrayAxisSum:\n", " if axis is not None and not isinstance(axis, (int, sp.Integer)):\n", " raise TypeError(\"Only single digits allowed for axis\")\n", " return create_expression(cls, array, axis, **hints)\n", @@ -1699,9 +1700,7 @@ "class ThreeMomentumNorm(UnevaluatedExpression):\n", " momentum: ArraySymbol = property(lambda self: self.args[0])\n", "\n", - " def __new__(\n", - " cls, momentum: ArraySymbol, **hints: Any\n", - " ) -> \"ThreeMomentumNorm\":\n", + " def __new__(cls, momentum: ArraySymbol, **hints) -> ThreeMomentumNorm:\n", " return create_expression(cls, momentum, **hints)\n", "\n", " def evaluate(self) -> ArraySlice:\n", @@ -1806,7 +1805,7 @@ "class Theta(UnevaluatedExpression):\n", " momentum: ArraySymbol = property(lambda self: self.args[0])\n", "\n", - " def __new__(cls, momentum: ArraySymbol, **hints: Any) -> \"Theta\":\n", + " def __new__(cls, momentum: ArraySymbol, **hints) -> Theta:\n", " return create_expression(cls, momentum, **hints)\n", "\n", " def evaluate(self) -> sp.Expr:\n", @@ -1944,7 +1943,7 @@ "source": [ "def create_event_collection_from_topology(\n", " topology: Topology,\n", - ") -> Dict[int, ArraySymbol]:\n", + ") -> dict[int, ArraySymbol]:\n", " n_final_states = len(topology.outgoing_edge_ids)\n", " return {i: ArraySymbol(f\"p{i}\") for i in range(n_final_states)}\n", "\n", @@ -1974,8 +1973,8 @@ "outputs": [], "source": [ "def compute_helicity_angles(\n", - " events: Dict[int, ArraySymbol], topology: Topology\n", - ") -> Dict[str, sp.Expr]:\n", + " events: dict[int, ArraySymbol], topology: Topology\n", + ") -> dict[str, sp.Expr]:\n", " if topology.outgoing_edge_ids != set(events):\n", " raise ValueError(\n", " f\"Momentum IDs {set(events)} do not match \"\n", @@ -1983,9 +1982,9 @@ " )\n", "\n", " def __recursive_helicity_angles(\n", - " events: Dict[int, ArraySymbol], node_id: int\n", - " ) -> Dict[str, sp.Expr]:\n", - " helicity_angles: Dict[str, sp.Expr] = {}\n", + " events: dict[int, ArraySymbol], node_id: int\n", + " ) -> dict[str, sp.Expr]:\n", + " helicity_angles: dict[str, sp.Expr] = {}\n", " child_state_ids = sorted(\n", " topology.get_edge_ids_outgoing_from_node(node_id)\n", " )\n", diff --git a/docs/report/014.ipynb b/docs/report/014.ipynb index 17500eb4..dd4f34d4 100644 --- a/docs/report/014.ipynb +++ b/docs/report/014.ipynb @@ -92,11 +92,13 @@ }, "outputs": [], "source": [ + "from __future__ import annotations\n", + "\n", "import inspect\n", "import itertools\n", "import logging\n", "from functools import lru_cache\n", - "from typing import Any, Iterable, List, Sequence, Tuple, Union\n", + "from typing import Iterable, Sequence\n", "\n", "import ampform\n", "import attrs\n", @@ -950,9 +952,9 @@ " def __new__(\n", " cls,\n", " expression: sp.Expr,\n", - " *indices: Tuple[sp.Symbol, Iterable[sp.Float]],\n", - " **hints: Any,\n", - " ) -> \"PoolSum\":\n", + " *indices: tuple[sp.Symbol, Iterable[sp.Float]],\n", + " **hints,\n", + " ) -> PoolSum:\n", " indices = tuple((s, tuple(v)) for s, v in indices)\n", " return create_expression(cls, expression, *indices, **hints)\n", "\n", @@ -961,7 +963,7 @@ " return self.args[0]\n", "\n", " @property\n", - " def indices(self) -> List[Tuple[sp.Symbol, Tuple[sp.Float, ...]]]:\n", + " def indices(self) -> list[tuple[sp.Symbol, tuple[sp.Float, ...]]]:\n", " return self.args[1:]\n", "\n", " def evaluate(self) -> sp.Expr:\n", @@ -971,15 +973,15 @@ " for combi in itertools.product(*indices.values())\n", " )\n", "\n", - " def _latex(self, printer: LatexPrinter, *args: Any) -> str:\n", + " def _latex(self, printer: LatexPrinter, *args) -> str:\n", " indices = dict(self.indices)\n", - " sum_symbols: List[str] = []\n", + " sum_symbols: list[str] = []\n", " for idx, values in indices.items():\n", " sum_symbols.append(_render_sum_symbol(printer, idx, values))\n", " expression = printer._print(self.expression)\n", " return R\" \".join(sum_symbols) + f\"{{{expression}}}\"\n", "\n", - " def cleanup(self) -> Union[sp.Expr, \"PoolSum\"]:\n", + " def cleanup(self) -> sp.Expr | PoolSum:\n", " substitutions = {}\n", " new_indices = []\n", " for idx, values in self.indices:\n", @@ -1284,7 +1286,6 @@ "source": [ "import sys\n", "from collections import defaultdict\n", - "from typing import Dict, Set\n", "\n", "from qrules import ReactionInfo\n", "\n", @@ -1297,7 +1298,7 @@ "@lru_cache(maxsize=None)\n", "def get_helicities(\n", " reaction: ReactionInfo, which: Literal[\"inner\", \"outer\"]\n", - ") -> Dict[int, Set[sp.Rational]]:\n", + ") -> dict[int, set[sp.Rational]]:\n", " helicities = defaultdict(set)\n", " initial_state_ids = set(reaction.initial_state)\n", " final_state_ids = set(reaction.final_state)\n", @@ -2046,7 +2047,7 @@ "source": [ "def formulate_intensity_with_dynamics(\n", " reaction: ReactionInfo,\n", - " dynamics_choices: Dict[str, ResonanceDynamicsBuilder],\n", + " dynamics_choices: dict[str, ResonanceDynamicsBuilder],\n", "):\n", " amplitudes = set()\n", " for transition in reaction.transitions:\n", @@ -2249,8 +2250,8 @@ "\n", "def formulate_intensity_indexed_amplitudes_only(\n", " reaction: ReactionInfo,\n", - " dynamics_choices: Dict[str, ResonanceDynamicsBuilder],\n", - ") -> Tuple[sp.Expr, Dict[sp.Indexed, sp.Expr]]:\n", + " dynamics_choices: dict[str, ResonanceDynamicsBuilder],\n", + ") -> tuple[sp.Expr, dict[sp.Indexed, sp.Expr]]:\n", " name_generator = HelicityAmplitudeNameGenerator()\n", " amplitudes = set()\n", " amplitude_definitions = {}\n", diff --git a/setup.cfg b/setup.cfg index e20df4e4..93d5b356 100644 --- a/setup.cfg +++ b/setup.cfg @@ -67,6 +67,7 @@ flake8 = flake8-bugbear flake8-builtins flake8-comprehensions + flake8-future-annotations flake8-pytest-style flake8-rst-docstrings flake8-type-ignore; python_version >="3.8.0"