diff --git a/.constraints/py3.10.txt b/.constraints/py3.10.txt index f4a5b745e..fd2b63017 100644 --- a/.constraints/py3.10.txt +++ b/.constraints/py3.10.txt @@ -15,12 +15,12 @@ attrs==21.4.0 babel==2.9.1 backcall==0.2.0 beautifulsoup4==4.10.0 -black==21.12b0 +black==22.1.0 bleach==4.1.0 certifi==2021.10.8 cffi==1.15.0 cfgv==3.3.1 -charset-normalizer==2.0.10 +charset-normalizer==2.0.11 click==8.0.3 colorama==0.4.4 commonmark==0.9.1 @@ -78,6 +78,8 @@ jupyter-server-mathjax==0.2.3 jupyter-sphinx==0.3.2 jupyterlab==3.2.8 jupyterlab-code-formatter==1.4.10 +jupyterlab-markup==1.0.1 +jupyterlab-myst==0.1.6 ; python_version >= "3.7.0" jupyterlab-pygments==0.1.2 jupyterlab-server==2.10.3 jupyterlab-widgets==1.0.2 @@ -164,6 +166,7 @@ soupsieve==2.3.1 sphinx==4.4.0 sphinx-autobuild==2021.3.14 sphinx-book-theme==0.2.0 +sphinx-codeautolink==0.10.0 sphinx-copybutton==0.4.0 sphinx-panels==0.6.0 sphinx-thebe==0.0.10 @@ -182,7 +185,7 @@ sympy==1.9 terminado==0.13.1 testpath==0.5.0 toml==0.10.2 -tomli==1.2.3 +tomli==2.0.0 tornado==6.1 tox==3.24.5 tqdm==4.62.3 @@ -190,7 +193,7 @@ traitlets==5.1.1 types-docutils==0.17.4 types-pkg-resources==0.1.3 types-requests==2.27.7 -types-setuptools==57.4.7 +types-setuptools==57.4.8 types-urllib3==1.26.7 typing-extensions==4.0.1 urllib3==1.26.8 diff --git a/.constraints/py3.6.txt b/.constraints/py3.6.txt index d186ce04f..06a6a9a1d 100644 --- a/.constraints/py3.6.txt +++ b/.constraints/py3.6.txt @@ -15,12 +15,12 @@ attrs==21.4.0 babel==2.9.1 backcall==0.2.0 beautifulsoup4==4.10.0 -black==21.12b0 +black==22.1.0 bleach==4.1.0 certifi==2021.10.8 cffi==1.15.0 cfgv==3.3.1 -charset-normalizer==2.0.10 +charset-normalizer==2.0.11 click==8.0.3 colorama==0.4.4 commonmark==0.9.1 @@ -162,6 +162,7 @@ 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-copybutton==0.4.0 sphinx-panels==0.6.0 sphinx-thebe==0.0.10 @@ -188,7 +189,7 @@ typed-ast==1.5.2 types-docutils==0.17.4 types-pkg-resources==0.1.3 types-requests==2.27.7 -types-setuptools==57.4.7 +types-setuptools==57.4.8 types-urllib3==1.26.7 typing-extensions==4.0.1 ; python_version < "3.8.0" urllib3==1.26.8 diff --git a/.constraints/py3.7.txt b/.constraints/py3.7.txt index 2ef9d3f6b..74b202d86 100644 --- a/.constraints/py3.7.txt +++ b/.constraints/py3.7.txt @@ -14,12 +14,12 @@ attrs==21.4.0 babel==2.9.1 backcall==0.2.0 beautifulsoup4==4.10.0 -black==21.12b0 +black==22.1.0 bleach==4.1.0 certifi==2021.10.8 cffi==1.15.0 cfgv==3.3.1 -charset-normalizer==2.0.10 +charset-normalizer==2.0.11 click==8.0.3 colorama==0.4.4 commonmark==0.9.1 @@ -76,6 +76,8 @@ jupyter-server-mathjax==0.2.3 jupyter-sphinx==0.3.2 jupyterlab==3.2.8 jupyterlab-code-formatter==1.4.10 +jupyterlab-markup==1.0.1 +jupyterlab-myst==0.1.6 ; python_version >= "3.7.0" jupyterlab-pygments==0.1.2 jupyterlab-server==2.10.3 jupyterlab-widgets==1.0.2 @@ -161,6 +163,7 @@ 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-copybutton==0.4.0 sphinx-panels==0.6.0 sphinx-thebe==0.0.10 @@ -178,7 +181,7 @@ sympy==1.9 terminado==0.13.1 testpath==0.5.0 toml==0.10.2 -tomli==1.2.3 +tomli==2.0.0 tornado==6.1 tox==3.24.5 tqdm==4.62.3 @@ -187,7 +190,7 @@ typed-ast==1.5.2 types-docutils==0.17.4 types-pkg-resources==0.1.3 types-requests==2.27.7 -types-setuptools==57.4.7 +types-setuptools==57.4.8 types-urllib3==1.26.7 typing-extensions==4.0.1 ; python_version < "3.8.0" urllib3==1.26.8 diff --git a/.constraints/py3.8.txt b/.constraints/py3.8.txt index ce67f40b5..cc007d027 100644 --- a/.constraints/py3.8.txt +++ b/.constraints/py3.8.txt @@ -15,12 +15,12 @@ attrs==21.4.0 babel==2.9.1 backcall==0.2.0 beautifulsoup4==4.10.0 -black==21.12b0 +black==22.1.0 bleach==4.1.0 certifi==2021.10.8 cffi==1.15.0 cfgv==3.3.1 -charset-normalizer==2.0.10 +charset-normalizer==2.0.11 click==8.0.3 colorama==0.4.4 commonmark==0.9.1 @@ -79,6 +79,8 @@ jupyter-server-mathjax==0.2.3 jupyter-sphinx==0.3.2 jupyterlab==3.2.8 jupyterlab-code-formatter==1.4.10 +jupyterlab-markup==1.0.1 +jupyterlab-myst==0.1.6 ; python_version >= "3.7.0" jupyterlab-pygments==0.1.2 jupyterlab-server==2.10.3 jupyterlab-widgets==1.0.2 @@ -165,6 +167,7 @@ soupsieve==2.3.1 sphinx==4.4.0 sphinx-autobuild==2021.3.14 sphinx-book-theme==0.2.0 +sphinx-codeautolink==0.10.0 sphinx-copybutton==0.4.0 sphinx-panels==0.6.0 sphinx-thebe==0.0.10 @@ -183,7 +186,7 @@ sympy==1.9 terminado==0.13.1 testpath==0.5.0 toml==0.10.2 -tomli==1.2.3 +tomli==2.0.0 tornado==6.1 tox==3.24.5 tqdm==4.62.3 @@ -191,7 +194,7 @@ traitlets==5.1.1 types-docutils==0.17.4 types-pkg-resources==0.1.3 types-requests==2.27.7 -types-setuptools==57.4.7 +types-setuptools==57.4.8 types-urllib3==1.26.7 typing-extensions==4.0.1 urllib3==1.26.8 diff --git a/.constraints/py3.9.txt b/.constraints/py3.9.txt index 02622b46e..3222bd1b5 100644 --- a/.constraints/py3.9.txt +++ b/.constraints/py3.9.txt @@ -15,12 +15,12 @@ attrs==21.4.0 babel==2.9.1 backcall==0.2.0 beautifulsoup4==4.10.0 -black==21.12b0 +black==22.1.0 bleach==4.1.0 certifi==2021.10.8 cffi==1.15.0 cfgv==3.3.1 -charset-normalizer==2.0.10 +charset-normalizer==2.0.11 click==8.0.3 colorama==0.4.4 commonmark==0.9.1 @@ -78,6 +78,8 @@ jupyter-server-mathjax==0.2.3 jupyter-sphinx==0.3.2 jupyterlab==3.2.8 jupyterlab-code-formatter==1.4.10 +jupyterlab-markup==1.0.1 +jupyterlab-myst==0.1.6 ; python_version >= "3.7.0" jupyterlab-pygments==0.1.2 jupyterlab-server==2.10.3 jupyterlab-widgets==1.0.2 @@ -164,6 +166,7 @@ soupsieve==2.3.1 sphinx==4.4.0 sphinx-autobuild==2021.3.14 sphinx-book-theme==0.2.0 +sphinx-codeautolink==0.10.0 sphinx-copybutton==0.4.0 sphinx-panels==0.6.0 sphinx-thebe==0.0.10 @@ -182,7 +185,7 @@ sympy==1.9 terminado==0.13.1 testpath==0.5.0 toml==0.10.2 -tomli==1.2.3 +tomli==2.0.0 tornado==6.1 tox==3.24.5 tqdm==4.62.3 @@ -190,7 +193,7 @@ traitlets==5.1.1 types-docutils==0.17.4 types-pkg-resources==0.1.3 types-requests==2.27.7 -types-setuptools==57.4.7 +types-setuptools==57.4.8 types-urllib3==1.26.7 typing-extensions==4.0.1 urllib3==1.26.8 diff --git a/.cspell.json b/.cspell.json index 2675cd30e..bbf6ff22b 100644 --- a/.cspell.json +++ b/.cspell.json @@ -143,6 +143,7 @@ "colorbar", "commitlint", "compwa", + "concat", "conds", "coolwarm", "displaystyle", diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 25088fdc4..8522d599b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -41,7 +41,7 @@ repos: - id: trailing-whitespace - repo: https://github.com/ComPWA/repo-maintenance - rev: 0.0.99 + rev: 0.0.101 hooks: - id: check-dev-files args: @@ -55,12 +55,12 @@ repos: - id: format-setup-cfg - repo: https://github.com/psf/black - rev: 21.12b0 + rev: 22.1.0 hooks: - id: black - repo: https://github.com/asottile/blacken-docs - rev: v1.12.0 + rev: v1.12.1 hooks: - id: blacken-docs @@ -101,6 +101,8 @@ repos: rev: 1.2.3 hooks: - id: nbqa-black + additional_dependencies: + - black>=22.1.0 - id: nbqa-flake8 - id: nbqa-isort - id: nbqa-pyupgrade diff --git a/docs/_extend_docstrings.py b/docs/_extend_docstrings.py index cbe2219e2..59b84f212 100644 --- a/docs/_extend_docstrings.py +++ b/docs/_extend_docstrings.py @@ -99,7 +99,7 @@ def extend_ComplexSqrt() -> None: expr = ComplexSqrt(x) _append_to_docstring( ComplexSqrt, - fR""" + Rf""" .. math:: {sp.latex(expr)} = {sp.latex(expr.evaluate())} :label: ComplexSqrt """, @@ -409,7 +409,7 @@ def extend_relativistic_breit_wigner_with_ff() -> None: ) _append_to_docstring( relativistic_breit_wigner_with_ff, - fR""" + Rf""" The general form of a relativistic Breit-Wigner with Blatt-Weisskopf form factor is: diff --git a/docs/conf.py b/docs/conf.py index 56a53d48a..74b4a2d85 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -118,6 +118,7 @@ def fetch_logo(url: str, output_path: str) -> None: "sphinx.ext.mathjax", "sphinx.ext.napoleon", "sphinx.ext.viewcode", + "sphinx_codeautolink", "sphinx_copybutton", "sphinx_panels", "sphinx_thebe", @@ -166,6 +167,7 @@ def fetch_logo(url: str, output_path: str) -> None: "Slider": "symplot.Slider", } autodoc_typehints_format = "short" +codeautolink_concat_default = True AUTODOC_INSERT_SIGNATURE_LINEBREAKS = False graphviz_output_format = "svg" html_copy_source = True # needed for download notebook button diff --git a/docs/usage/amplitude.ipynb b/docs/usage/amplitude.ipynb index 957531788..b64f3e568 100644 --- a/docs/usage/amplitude.ipynb +++ b/docs/usage/amplitude.ipynb @@ -49,6 +49,14 @@ "%pip install -q ampform[doc,viz] IPython" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "```{autolink-concat}\n", + "```" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -874,7 +882,7 @@ " plotted_intensity,\n", " (m, 2 * pi0.mass, 2.5),\n", " axis_center=(2 * pi0.mass, 0),\n", - " xlabel=fR\"$m(\\pi^{0}\\pi^{0})$\",\n", + " xlabel=Rf\"$m(\\pi^{0}\\pi^{0})$\",\n", " ylabel=\"$I$\",\n", " backend=\"matplotlib\",\n", ");" diff --git a/docs/usage/dynamics.ipynb b/docs/usage/dynamics.ipynb index 805b84e37..6712f863e 100644 --- a/docs/usage/dynamics.ipynb +++ b/docs/usage/dynamics.ipynb @@ -49,6 +49,14 @@ "%pip install -q ampform[doc,viz] IPython" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "```{autolink-concat}\n", + "```" + ] + }, { "cell_type": "markdown", "metadata": { @@ -162,9 +170,9 @@ "from ampform.dynamics import BreakupMomentumSquared\n", "\n", "m, m_a, m_b, d = sp.symbols(\"m, m_a, m_b, d\")\n", - "s = m ** 2\n", + "s = m**2\n", "q_squared = BreakupMomentumSquared(s, m_a, m_b)\n", - "ff2 = BlattWeisskopfSquared(L, z=q_squared * d ** 2)" + "ff2 = BlattWeisskopfSquared(L, z=q_squared * d**2)" ] }, { @@ -316,7 +324,7 @@ "from ampform.dynamics import relativistic_breit_wigner\n", "\n", "m, m0, w0 = sp.symbols(\"m, m0, Gamma0\")\n", - "rel_bw = relativistic_breit_wigner(s=m ** 2, mass0=m0, gamma0=w0)\n", + "rel_bw = relativistic_breit_wigner(s=m**2, mass0=m0, gamma0=w0)\n", "rel_bw" ] }, diff --git a/docs/usage/dynamics/analytic-continuation.ipynb b/docs/usage/dynamics/analytic-continuation.ipynb index f8d09aa8d..286f97f8e 100644 --- a/docs/usage/dynamics/analytic-continuation.ipynb +++ b/docs/usage/dynamics/analytic-continuation.ipynb @@ -49,6 +49,14 @@ "%pip install -q ampform[doc,viz] IPython" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "```{autolink-concat}\n", + "```" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -288,14 +296,14 @@ "from ampform.dynamics import ComplexSqrt\n", "\n", "m = sp.Symbol(\"m\", real=True)\n", - "rho_c = PhaseSpaceFactorComplex(m ** 2, m_a, m_b)\n", - "rho_ac = PhaseSpaceFactorAnalytic(m ** 2, m_a, m_b)\n", + "rho_c = PhaseSpaceFactorComplex(m**2, m_a, m_b)\n", + "rho_ac = PhaseSpaceFactorAnalytic(m**2, m_a, m_b)\n", "np_rho_c, sliders = symplot.prepare_sliders(\n", " plot_symbol=m, expression=rho_c.doit()\n", ")\n", "np_rho_ac = sp.lambdify((m, m_a, m_b), rho_ac.doit())\n", "np_breakup_momentum = sp.lambdify(\n", - " (m, m_a, m_b), ComplexSqrt(q_squared.subs(s, m ** 2).doit())\n", + " (m, m_a, m_b), ComplexSqrt(q_squared.subs(s, m**2).doit())\n", ")" ] }, diff --git a/docs/usage/dynamics/custom.ipynb b/docs/usage/dynamics/custom.ipynb index aaa06d0a0..e3cb26904 100644 --- a/docs/usage/dynamics/custom.ipynb +++ b/docs/usage/dynamics/custom.ipynb @@ -49,6 +49,14 @@ "%pip install -q ampform[doc,viz] IPython" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "```{autolink-concat}\n", + "```" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -181,7 +189,7 @@ "outputs": [], "source": [ "def my_dynamics(x: sp.Symbol, mu: sp.Symbol, sigma: sp.Symbol) -> sp.Expr:\n", - " return sp.exp(-((x - mu) ** 2) / sigma ** 2 / 2) / (\n", + " return sp.exp(-((x - mu) ** 2) / sigma**2 / 2) / (\n", " sigma * sp.sqrt(2 * sp.pi)\n", " )" ] diff --git a/docs/usage/dynamics/k-matrix.ipynb b/docs/usage/dynamics/k-matrix.ipynb index 20c84af8d..1110a0dec 100644 --- a/docs/usage/dynamics/k-matrix.ipynb +++ b/docs/usage/dynamics/k-matrix.ipynb @@ -49,6 +49,14 @@ "%pip install -q ampform[doc,viz] IPython" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "```{autolink-concat}\n", + "```" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -705,8 +713,8 @@ "gamma1, gamma2 = sp.symbols(\"gamma1 gamma2\")\n", "bw = symplot.rename_symbols(bw, rename_gammas)\n", "k_matrix = symplot.rename_symbols(k_matrix, rename_gammas)\n", - "bw = bw.xreplace({s: m ** 2})\n", - "k_matrix = k_matrix.xreplace({s: m ** 2})\n", + "bw = bw.xreplace({s: m**2})\n", + "k_matrix = k_matrix.xreplace({s: m**2})\n", "\n", "# Prepare sliders and domain\n", "np_kmatrix, sliders = symplot.prepare_sliders(k_matrix, m)\n", @@ -1136,7 +1144,7 @@ "bw_with_phases = symplot.rename_symbols(bw_with_phases, rename_gammas)\n", "f_vector = symplot.rename_symbols(f_vector, rename_gammas)\n", "substitutions = {\n", - " s: m ** 2,\n", + " s: m**2,\n", " beta1: c1 * sp.exp(sp.I * phi1),\n", " beta2: c2 * sp.exp(sp.I * phi2),\n", "}\n", @@ -1483,7 +1491,7 @@ " ).xreplace(\n", " {sp.conjugate(sp.sqrt(rho_i(i))): 1 for i in range(n_channels)}\n", " )\n", - " expr = expr.xreplace({s: m ** 2})\n", + " expr = expr.xreplace({s: m**2})\n", " expr = symplot.substitute_indexed_symbols(expr)\n", " np_expr, sliders = symplot.prepare_sliders(expr, m)\n", "\n", @@ -1515,8 +1523,8 @@ " sliders.set_ranges(\n", " {\n", " f\"m{R}\": (0, 3, 100),\n", - " fR\"\\Gamma_{{{R},{i}}}\": (-2, +2, 100),\n", - " fR\"\\gamma_{{{R},{i}}}\": (0, 10, 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", @@ -1524,9 +1532,9 @@ " sliders.set_values(\n", " {\n", " f\"m{R}\": m0_values[R - 1],\n", - " fR\"\\Gamma_{{{R},{i}}}\": 2.0\n", + " Rf\"\\Gamma_{{{R},{i}}}\": 2.0\n", " * (0.4 + R * 0.2 - i * 0.3),\n", - " fR\"\\gamma_{{{R},{i}}}\": 0.25 * (10 - R + i),\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", @@ -1538,15 +1546,15 @@ " sliders.set_ranges(\n", " {\n", " f\"m{R}\": (0, 3, 100),\n", - " fR\"\\Gamma_{{{R},{i}}}\": (-1, 1, 100),\n", - " fR\"\\gamma_{{{R},{i}}}\": (0, 2, 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", - " fR\"\\Gamma_{{{R},{i}}}\": (R + 1) * 0.1,\n", - " fR\"\\gamma_{{{R},{i}}}\": 1 - 0.1 * R + 0.1 * i,\n", + " Rf\"\\Gamma_{{{R},{i}}}\": (R + 1) * 0.1,\n", + " Rf\"\\gamma_{{{R},{i}}}\": 1 - 0.1 * R + 0.1 * i,\n", " }\n", " )\n", " if kmatrix_type in {\n", @@ -1571,7 +1579,7 @@ " kmatrix.RelativisticKMatrix,\n", " }:\n", " fig.suptitle(\n", - " fR\"${n_channels} \\times {n_channels}$ $K$-matrix\"\n", + " Rf\"${n_channels} \\times {n_channels}$ $K$-matrix\"\n", " f\" with {n_poles} resonances\"\n", " )\n", " elif kmatrix_type in {\n", @@ -1760,8 +1768,8 @@ " buttons = [sliders_copy.pop(f\"m{R}\")]\n", " if n_channels == 1:\n", " buttons += [\n", - " sliders_copy.pop(sliders.symbol_to_arg[fR\"\\Gamma_{{{R},0}}\"]),\n", - " sliders_copy.pop(sliders.symbol_to_arg[fR\"\\gamma_{{{R},0}}\"]),\n", + " sliders_copy.pop(sliders.symbol_to_arg[Rf\"\\Gamma_{{{R},0}}\"]),\n", + " sliders_copy.pop(sliders.symbol_to_arg[Rf\"\\gamma_{{{R},0}}\"]),\n", " ]\n", " h_box = ipywidgets.HBox(buttons)\n", " h_boxes.append(h_box)\n", diff --git a/docs/usage/formalism.ipynb b/docs/usage/formalism.ipynb index 94690ba64..d50a9d7a1 100644 --- a/docs/usage/formalism.ipynb +++ b/docs/usage/formalism.ipynb @@ -49,6 +49,14 @@ "%pip install -q ampform[doc,viz] IPython" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "```{autolink-concat}\n", + "```" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -202,7 +210,7 @@ " name = \"a\" + name[1:]\n", " if colorize:\n", " color = next(color_iter)\n", - " name = fR\"\\color{{{color}}}{{{name}}}\"\n", + " name = Rf\"\\color{{{color}}}{{{name}}}\"\n", " symbol = sp.Symbol(name)\n", " amplitude_to_symbol[expr] = symbol\n", " return amplitude_to_symbol\n", @@ -221,9 +229,9 @@ " terms = collected_expr.args\n", " latex = \"\"\n", " latex += R\"\\begin{align}\"\n", - " latex += fR\"\\sum_i A_i & = {sp.latex(terms[0])}\\\\\"\n", + " latex += Rf\"\\sum_i A_i & = {sp.latex(terms[0])}\\\\\"\n", " for term in terms[1:]:\n", - " latex += fR\"& + {sp.latex(term)} \\\\\"\n", + " latex += Rf\"& + {sp.latex(term)} \\\\\"\n", " latex += R\"\\end{align}\"\n", " return Math(latex)\n", "\n", @@ -288,7 +296,7 @@ "heli_amplitudes = extract_amplitudes(heli_model)\n", "\n", "expression, symbol = next(iter(cano_amplitude_to_symbol.items()))\n", - "display(symbol, Math(fR\"\\quad = {sp.latex(expression)}\"))" + "display(symbol, Math(Rf\"\\quad = {sp.latex(expression)}\"))" ] }, { @@ -312,7 +320,7 @@ "outputs": [], "source": [ "expression, symbol = next(iter(heli_amplitude_to_symbol.items()))\n", - "display(symbol, Math(fR\"\\quad = {sp.latex(expression)}\"))" + "display(symbol, Math(Rf\"\\quad = {sp.latex(expression)}\"))" ] }, { diff --git a/docs/usage/interactive.ipynb b/docs/usage/interactive.ipynb index f644ed56e..9cbc16752 100644 --- a/docs/usage/interactive.ipynb +++ b/docs/usage/interactive.ipynb @@ -49,6 +49,14 @@ "%pip install -q ampform[doc,viz] IPython" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "```{autolink-concat}\n", + "```" + ] + }, { "cell_type": "markdown", "metadata": { diff --git a/docs/usage/modify.ipynb b/docs/usage/modify.ipynb index f717de2b3..ba46242cf 100644 --- a/docs/usage/modify.ipynb +++ b/docs/usage/modify.ipynb @@ -49,6 +49,14 @@ "%pip install -q ampform[doc,viz] IPython" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "```{autolink-concat}\n", + "```" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -209,7 +217,7 @@ " positive=True,\n", " )\n", " phase = sp.Symbol(\n", - " fR\"\\phi_{{{decay_description}}}\",\n", + " Rf\"\\phi_{{{decay_description}}}\",\n", " real=True,\n", " )\n", " replacement = magnitude * sp.exp(sp.I * phase)\n", diff --git a/docs/usage/symplot.ipynb b/docs/usage/symplot.ipynb index 90c48dc17..9e8a6f64f 100644 --- a/docs/usage/symplot.ipynb +++ b/docs/usage/symplot.ipynb @@ -49,6 +49,14 @@ "%pip install -q ampform[doc,viz] IPython" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "```{autolink-concat}\n", + "```" + ] + }, { "cell_type": "markdown", "metadata": {}, diff --git a/pyproject.toml b/pyproject.toml index 3c9a2925b..1bfd2ecd0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -22,9 +22,9 @@ exclude = ''' | dist )/ ''' -experimental-string-processing = true include = '\.pyi?$' line-length = 79 +preview = true target-version = [ "py36", "py37", diff --git a/setup.cfg b/setup.cfg index f695e0946..fac47e9ae 100644 --- a/setup.cfg +++ b/setup.cfg @@ -70,6 +70,7 @@ doc = Sphinx >=3 Sphinx <4.4; python_version <"3.8.0" # https://github.com/ComPWA/qrules/runs/4833302679 sphinx-book-theme + sphinx-codeautolink[ipython] sphinx-copybutton sphinx-panels sphinx-thebe @@ -125,6 +126,7 @@ dev = aquirdturtle_collapsible_headings jupyterlab jupyterlab-code-formatter + jupyterlab-myst; python_version >="3.7.0" pip-tools >=6.3.0 # for extras_require and direct references sphinx-autobuild tox >=1.9 # for skip_install, use_develop diff --git a/src/ampform/dynamics/__init__.py b/src/ampform/dynamics/__init__.py index 2db2ffbf7..a540bde74 100644 --- a/src/ampform/dynamics/__init__.py +++ b/src/ampform/dynamics/__init__.py @@ -73,63 +73,63 @@ def evaluate(self) -> sp.Expr: cases: Dict[int, sp.Expr] = { 0: 1, 1: 2 * z / (z + 1), - 2: 13 * z ** 2 / ((z - 3) * (z - 3) + 9 * z), + 2: 13 * z**2 / ((z - 3) * (z - 3) + 9 * z), 3: ( 277 - * z ** 3 + * z**3 / (z * (z - 15) * (z - 15) + 9 * (2 * z - 5) * (2 * z - 5)) ), 4: ( 12746 - * z ** 4 + * z**4 / ( - (z ** 2 - 45 * z + 105) * (z ** 2 - 45 * z + 105) + (z**2 - 45 * z + 105) * (z**2 - 45 * z + 105) + 25 * z * (2 * z - 21) * (2 * z - 21) ) ), 5: 998881 - * z ** 5 + * z**5 / ( - z ** 5 - + 15 * z ** 4 - + 315 * z ** 3 - + 6300 * z ** 2 + z**5 + + 15 * z**4 + + 315 * z**3 + + 6300 * z**2 + 99225 * z + 893025 ), 6: 118394977 - * z ** 6 + * z**6 / ( - z ** 6 - + 21 * z ** 5 - + 630 * z ** 4 - + 18900 * z ** 3 - + 496125 * z ** 2 + z**6 + + 21 * z**5 + + 630 * z**4 + + 18900 * z**3 + + 496125 * z**2 + 9823275 * z + 108056025 ), 7: 19727003738 - * z ** 7 + * z**7 / ( - z ** 7 - + 28 * z ** 6 - + 1134 * z ** 5 - + 47250 * z ** 4 - + 1819125 * z ** 3 - + 58939650 * z ** 2 + z**7 + + 28 * z**6 + + 1134 * z**5 + + 47250 * z**4 + + 1819125 * z**3 + + 58939650 * z**2 + 1404728325 * z + 18261468225 ), 8: 4392846440677 - * z ** 8 + * z**8 / ( - z ** 8 - + 36 * z ** 7 - + 1890 * z ** 6 - + 103950 * z ** 5 - + 5457375 * z ** 4 - + 255405150 * z ** 3 - + 9833098275 * z ** 2 + z**8 + + 36 * z**7 + + 1890 * z**6 + + 103950 * z**5 + + 5457375 * z**4 + + 255405150 * z**3 + + 9833098275 * z**2 + 273922023375 * z + 4108830350625 ), @@ -145,7 +145,7 @@ def evaluate(self) -> sp.Expr: def _latex(self, printer: LatexPrinter, *args: Any) -> str: angular_momentum, z = tuple(map(printer._print, self.args)) - return fR"B_{{{angular_momentum}}}^2\left({z}\right)" + return Rf"B_{{{angular_momentum}}}^2\left({z}\right)" class PhaseSpaceFactorProtocol(Protocol): @@ -188,7 +188,7 @@ def _latex(self, printer: LatexPrinter, *args: Any) -> str: s = printer._print(s) subscript = _indices_to_subscript(_determine_indices(s)) name = R"\rho" + subscript if self._name is None else self._name - return fR"{name}\left({s}\right)" + return Rf"{name}\left({s}\right)" @implement_doit_method @@ -223,7 +223,7 @@ def _latex(self, printer: LatexPrinter, *args: Any) -> str: s = printer._print(s) subscript = _indices_to_subscript(_determine_indices(s)) name = R"\hat{\rho}" + subscript if self._name is None else self._name - return fR"{name}\left({s}\right)" + return Rf"{name}\left({s}\right)" @implement_doit_method @@ -259,7 +259,7 @@ def _latex(self, printer: LatexPrinter, *args: Any) -> str: if self._name is None else self._name ) - return fR"{name}\left({s}\right)" + return Rf"{name}\left({s}\right)" @implement_doit_method @@ -292,7 +292,7 @@ def _latex(self, printer: LatexPrinter, *args: Any) -> str: if self._name is None else self._name ) - return fR"{name}\left({s}\right)" + return Rf"{name}\left({s}\right)" def _analytic_continuation( @@ -377,23 +377,23 @@ def __getnewargs__(self) -> tuple: def evaluate(self) -> sp.Expr: s, mass0, gamma0, m_a, m_b, angular_momentum, meson_radius = self.args q_squared = BreakupMomentumSquared(s, m_a, m_b) - q0_squared = BreakupMomentumSquared(mass0 ** 2, m_a, m_b) + q0_squared = BreakupMomentumSquared(mass0**2, m_a, m_b) form_factor_sq = BlattWeisskopfSquared( - angular_momentum, z=q_squared * meson_radius ** 2 + angular_momentum, z=q_squared * meson_radius**2 ) form_factor0_sq = BlattWeisskopfSquared( - angular_momentum, z=q0_squared * meson_radius ** 2 + angular_momentum, z=q0_squared * meson_radius**2 ) rho = self.phsp_factor(s, m_a, m_b) - rho0 = self.phsp_factor(mass0 ** 2, m_a, m_b) + rho0 = self.phsp_factor(mass0**2, m_a, m_b) return gamma0 * (form_factor_sq / form_factor0_sq) * (rho / rho0) def _latex(self, printer: LatexPrinter, *args: Any) -> str: s, _, width, *_ = self.args s = printer._print(s) subscript = _indices_to_subscript(_determine_indices(width)) - name = fR"\Gamma{subscript}" if self._name is None else self._name - return fR"{name}\left({s}\right)" + name = Rf"\Gamma{subscript}" if self._name is None else self._name + return Rf"{name}\left({s}\right)" @implement_doit_method @@ -433,7 +433,7 @@ def _latex(self, printer: LatexPrinter, *args: Any) -> str: s = printer._print(s) subscript = _indices_to_subscript(_determine_indices(s)) name = "q^2" + subscript if self._name is None else self._name - return fR"{name}\left({s}\right)" + return Rf"{name}\left({s}\right)" def relativistic_breit_wigner( @@ -444,7 +444,7 @@ def relativistic_breit_wigner( See :ref:`usage/dynamics:_Without_ form factor` and :cite:`asnerDalitzPlotAnalysis2006`. """ - return gamma0 * mass0 / (mass0 ** 2 - s - gamma0 * mass0 * sp.I) + return gamma0 * mass0 / (mass0**2 - s - gamma0 * mass0 * sp.I) def relativistic_breit_wigner_with_ff( # pylint: disable=too-many-arguments @@ -464,14 +464,14 @@ def relativistic_breit_wigner_with_ff( # pylint: disable=too-many-arguments """ q_squared = BreakupMomentumSquared(s, m_a, m_b) ff_squared = BlattWeisskopfSquared( - angular_momentum, z=q_squared * meson_radius ** 2 + angular_momentum, z=q_squared * meson_radius**2 ) form_factor = sp.sqrt(ff_squared) mass_dependent_width = EnergyDependentWidth( s, mass0, gamma0, m_a, m_b, angular_momentum, meson_radius, phsp_factor ) return (mass0 * gamma0 * form_factor) / ( - mass0 ** 2 - s - mass_dependent_width * mass0 * sp.I + mass0**2 - s - mass_dependent_width * mass0 * sp.I ) diff --git a/src/ampform/dynamics/builder.py b/src/ampform/dynamics/builder.py index 6a30cd965..6e8f0cd4f 100644 --- a/src/ampform/dynamics/builder.py +++ b/src/ampform/dynamics/builder.py @@ -93,14 +93,14 @@ def create_non_dynamic_with_ff( " factor!" ) q_squared = BreakupMomentumSquared( - s=variable_pool.incoming_state_mass ** 2, + s=variable_pool.incoming_state_mass**2, m_a=variable_pool.outgoing_state_mass1, m_b=variable_pool.outgoing_state_mass2, ) meson_radius = sp.Symbol(f"d_{resonance.name}") form_factor_squared = BlattWeisskopfSquared( angular_momentum, - z=q_squared * meson_radius ** 2, + z=q_squared * meson_radius**2, ) return ( sp.sqrt(form_factor_squared), @@ -150,7 +150,7 @@ def __formulate( res_mass = sp.Symbol(f"m_{resonance.name}") res_width = sp.Symbol(f"Gamma_{resonance.name}") expression = relativistic_breit_wigner( - s=inv_mass ** 2, + s=inv_mass**2, mass0=res_mass, gamma0=res_width, ) @@ -178,7 +178,7 @@ def __formulate_with_form_factor( meson_radius = sp.Symbol(f"d_{resonance.name}") expression = relativistic_breit_wigner_with_ff( - s=inv_mass ** 2, + s=inv_mass**2, mass0=res_mass, gamma0=res_width, m_a=product1_inv_mass, diff --git a/src/ampform/dynamics/kmatrix.py b/src/ampform/dynamics/kmatrix.py index 85709624b..e66a04871 100644 --- a/src/ampform/dynamics/kmatrix.py +++ b/src/ampform/dynamics/kmatrix.py @@ -282,7 +282,7 @@ def parametrization( # pylint: disable=too-many-arguments gamma = residue_constant[pole_id, i] mass = pole_position[pole_id] width = pole_width[pole_id, i] - parametrization = beta * gamma * mass * width / (mass ** 2 - s) + parametrization = beta * gamma * mass * width / (mass**2 - s) return sp.Sum(parametrization, (pole_id, 1, n_poles)) @@ -414,11 +414,11 @@ def parametrization( # pylint: disable=too-many-arguments, too-many-locals width = pole_width[pole_id, i] q_squared = BreakupMomentumSquared(s, m_a[i], m_b[i]) form_factor_squared = BlattWeisskopfSquared( - angular_momentum, z=q_squared * meson_radius ** 2 + angular_momentum, z=q_squared * meson_radius**2 ) form_factor = sp.sqrt(form_factor_squared) return sp.Sum( - beta * gamma * mass0 * width * form_factor / (mass0 ** 2 - s), + beta * gamma * mass0 * width * form_factor / (mass0**2 - s), (pole_id, 1, n_poles), ) diff --git a/src/ampform/helicity/__init__.py b/src/ampform/helicity/__init__.py index 456d70627..9c3ec47ac 100644 --- a/src/ampform/helicity/__init__.py +++ b/src/ampform/helicity/__init__.py @@ -330,7 +330,7 @@ def __formulate_coherent_intensity( sequential_expressions.append(expression) amplitude_sum = sum(sequential_expressions) coherent_intensity = abs(amplitude_sum) ** 2 - self.__components[fR"I_{{{graph_group_label}}}"] = coherent_intensity + self.__components[Rf"I_{{{graph_group_label}}}"] = coherent_intensity return coherent_intensity def __formulate_sequential_decay( diff --git a/src/ampform/helicity/naming.py b/src/ampform/helicity/naming.py index 6b0720765..46b447ecd 100644 --- a/src/ampform/helicity/naming.py +++ b/src/ampform/helicity/naming.py @@ -173,7 +173,7 @@ def __generate_ls_arrow(transition: StateTransition, node_id: int) -> str: interaction = transition.interactions[node_id] angular_momentum = sp.Rational(interaction.l_magnitude) coupled_spin = sp.Rational(interaction.s_magnitude) - return fR" \xrightarrow[S={coupled_spin}]{{L={angular_momentum}}} " + return Rf" \xrightarrow[S={coupled_spin}]{{L={angular_momentum}}} " def generate_transition_label(transition: StateTransition) -> str: diff --git a/src/ampform/kinematics.py b/src/ampform/kinematics.py index 6d315ac12..af306a882 100644 --- a/src/ampform/kinematics.py +++ b/src/ampform/kinematics.py @@ -181,7 +181,7 @@ def evaluate(self) -> ArraySlice: def _latex(self, printer: LatexPrinter, *args: Any) -> str: momentum = printer._print(self._momentum) - return fR"E\left({momentum}\right)" + return Rf"E\left({momentum}\right)" @_implement_latex_subscript(subscript="x") @@ -259,12 +259,12 @@ def evaluate(self) -> ArraySlice: three_momentum = ArraySlice( self._momentum, (slice(None), slice(1, None)) ) - norm_squared = ArrayAxisSum(three_momentum ** 2, axis=1) + norm_squared = ArrayAxisSum(three_momentum**2, axis=1) return sp.sqrt(norm_squared) def _latex(self, printer: LatexPrinter, *args: Any) -> str: momentum = printer._print(self._momentum) - return fR"\left|\vec{{{momentum}}}\right|" + return Rf"\left|\vec{{{momentum}}}\right|" def _numpycode(self, printer: NumPyPrinter, *args: Any) -> str: return printer._print(self.evaluate()) @@ -309,7 +309,7 @@ def evaluate(self) -> sp.Expr: def _latex(self, printer: LatexPrinter, *args: Any) -> str: momentum = printer._print(self._momentum) - return fR"\phi\left({momentum}\right)" + return Rf"\phi\left({momentum}\right)" @implement_doit_method @@ -330,7 +330,7 @@ def evaluate(self) -> sp.Expr: def _latex(self, printer: LatexPrinter, *args: Any) -> str: momentum = printer._print(self._momentum) - return fR"\theta\left({momentum}\right)" + return Rf"\theta\left({momentum}\right)" class BoostZMatrix(sp.Expr): @@ -346,7 +346,7 @@ def beta(self) -> sp.Expr: def as_explicit(self) -> sp.Expr: beta = self.beta - gamma = 1 / sp.sqrt(1 - beta ** 2) + gamma = 1 / sp.sqrt(1 - beta**2) return sp.Matrix( [ [gamma, 0, 0, -gamma * beta], @@ -358,7 +358,7 @@ def as_explicit(self) -> sp.Expr: def _latex(self, printer: LatexPrinter, *args: Any) -> str: beta = printer._print(self.beta) - return fR"\boldsymbol{{B_z}}\left({beta}\right)" + return Rf"\boldsymbol{{B_z}}\left({beta}\right)" def _numpycode(self, printer: NumPyPrinter, *args: Any) -> str: printer.module_imports[printer._module].update( @@ -404,7 +404,7 @@ def as_explicit(self) -> sp.Expr: def _latex(self, printer: LatexPrinter, *args: Any) -> str: angle, *_ = self.args angle = printer._print(angle) - return fR"\boldsymbol{{R_y}}\left({angle}\right)" + return Rf"\boldsymbol{{R_y}}\left({angle}\right)" def _numpycode(self, printer: NumPyPrinter, *args: Any) -> str: printer.module_imports[printer._module].update( @@ -449,7 +449,7 @@ def as_explicit(self) -> sp.Expr: def _latex(self, printer: LatexPrinter, *args: Any) -> str: angle, *_ = self.args angle = printer._print(angle) - return fR"\boldsymbol{{R_z}}\left({angle}\right)" + return Rf"\boldsymbol{{R_z}}\left({angle}\right)" def _numpycode(self, printer: NumPyPrinter, *args: Any) -> str: printer.module_imports[printer._module].update( diff --git a/src/ampform/sympy/__init__.py b/src/ampform/sympy/__init__.py index 0c8295730..8fcdbbc96 100644 --- a/src/ampform/sympy/__init__.py +++ b/src/ampform/sympy/__init__.py @@ -138,9 +138,9 @@ def decorator( def _latex(self: sp.Expr, printer: LatexPrinter, *args: Any) -> str: momentum = printer._print(self._momentum) if printer._needs_mul_brackets(self._momentum): - momentum = fR"\left({momentum}\right)" + momentum = Rf"\left({momentum}\right)" else: - momentum = fR"{{{momentum}}}" + momentum = Rf"{{{momentum}}}" return f"{momentum}_{subscript}" decorated_class._latex = _latex # type: ignore[assignment] diff --git a/src/ampform/sympy/_array_expressions.py b/src/ampform/sympy/_array_expressions.py index 1735779d3..83a988704 100644 --- a/src/ampform/sympy/_array_expressions.py +++ b/src/ampform/sympy/_array_expressions.py @@ -223,7 +223,7 @@ def _print_latex_ArraySlice( # noqa: N802 stringified_indices.append(_slice_to_str(self, idx, axis_size)) parent = self.parenthesize(expr.parent, PRECEDENCE["Func"], strict=True) indices = ", ".join(stringified_indices) - return fR"{parent}\left[{indices}\right]" + return Rf"{parent}\left[{indices}\right]" def _print_str_ArrayElement( # noqa: N802 @@ -352,9 +352,9 @@ def axis(self) -> Optional[int]: def _latex(self, printer: LatexPrinter, *args: Any) -> str: array = printer._print(self.array) if self.axis is None: - return fR"\sum{{{array}}}" + return Rf"\sum{{{array}}}" axis = printer._print(self.axis) - return fR"\sum_{{\mathrm{{axis{axis}}}}}{{{array}}}" + return Rf"\sum_{{\mathrm{{axis{axis}}}}}{{{array}}}" def _numpycode(self, printer: NumPyPrinter, *args: Any) -> str: printer.module_imports[printer._module].add("sum") diff --git a/src/ampform/sympy/math.py b/src/ampform/sympy/math.py index eb508e83c..d774a83d0 100644 --- a/src/ampform/sympy/math.py +++ b/src/ampform/sympy/math.py @@ -42,7 +42,7 @@ def _evaluate_complex(x: sp.Expr) -> sp.Expr: def _latex(self, printer: Printer, *args: Any) -> str: x = printer._print(self.args[0]) - return fR"\sqrt[\mathrm{{c}}]{{{x}}}" + return Rf"\sqrt[\mathrm{{c}}]{{{x}}}" def _numpycode(self, printer: Printer, *args: Any) -> str: return self.__print_complex(printer) diff --git a/src/symplot/__init__.py b/src/symplot/__init__.py index 2d5371ae5..c8ffc005b 100644 --- a/src/symplot/__init__.py +++ b/src/symplot/__init__.py @@ -303,7 +303,7 @@ def create_slider(symbol: sp.Symbol) -> "Slider": >>> create_slider(sp.Symbol("n0", integer=True)) IntSlider(value=0, description='\\(n_{0}\\)') """ - description = fR"\({sp.latex(symbol)}\)" + description = Rf"\({sp.latex(symbol)}\)" if symbol.is_integer: return IntSlider(description=description) return FloatSlider(description=description) diff --git a/tests/dynamics/test_kmatrix.py b/tests/dynamics/test_kmatrix.py index 908d8ecaa..901cca038 100644 --- a/tests/dynamics/test_kmatrix.py +++ b/tests/dynamics/test_kmatrix.py @@ -25,7 +25,7 @@ def test_breit_wigner(self, n_channels: int): if n_channels > 1: factor += f"{n_channels}" factor += "*" - assert str(breit_wigner) == fR"-m1*w1/(-m1**2 + {factor}I*m1*w1 + s)" + assert str(breit_wigner) == Rf"-m1*w1/(-m1**2 + {factor}I*m1*w1 + s)" def test_interference_single_channel(self): k_matrix = NonRelativisticKMatrix.formulate(n_poles=2, n_channels=1) diff --git a/tests/helicity/test_helicity.py b/tests/helicity/test_helicity.py index 3278e8819..ec953be7b 100644 --- a/tests/helicity/test_helicity.py +++ b/tests/helicity/test_helicity.py @@ -122,8 +122,8 @@ def test_sum_components(self, amplitude_model: Tuple[str, HelicityModel]): assert from_intensities == model.expression for spin_jpsi in ["-1", "+1"]: for spin_gamma in ["-1", "+1"]: - jpsi_with_spin = fR"J/\psi(1S)_{{{spin_jpsi}}}" - gamma_with_spin = fR"\gamma_{{{spin_gamma}}}" + jpsi_with_spin = Rf"J/\psi(1S)_{{{spin_jpsi}}}" + gamma_with_spin = Rf"\gamma_{{{spin_gamma}}}" from_amplitudes = model.sum_components( components=filter( lambda c: c.startswith("A") diff --git a/tests/helicity/test_naming.py b/tests/helicity/test_naming.py index 1ed688b34..818b0d6db 100644 --- a/tests/helicity/test_naming.py +++ b/tests/helicity/test_naming.py @@ -9,6 +9,6 @@ def test_generate_transition_label(reaction: ReactionInfo): jpsi_spin = _render_float(transition.states[-1].spin_projection) gamma_spin = _render_float(transition.states[0].spin_projection) assert label == ( - fR"J/\psi(1S)_{{{jpsi_spin}}} \to \gamma_{{{gamma_spin}}}" + Rf"J/\psi(1S)_{{{jpsi_spin}}} \to \gamma_{{{gamma_spin}}}" R" \pi^{0}_{0} \pi^{0}_{0}" ) diff --git a/tests/sympy/test_array_expressions.py b/tests/sympy/test_array_expressions.py index 932ac5dba..af3bde4dd 100644 --- a/tests/sympy/test_array_expressions.py +++ b/tests/sympy/test_array_expressions.py @@ -33,7 +33,7 @@ def test_numpy_str(self): class TestArraySum: def test_latex(self): x, y = sp.symbols("x y") - array_sum = ArraySum(x ** 2, sp.cos(y)) + array_sum = ArraySum(x**2, sp.cos(y)) assert sp.latex(array_sum) == R"x^{2} + \cos{\left(y \right)}" def test_latex_array_symbols(self): diff --git a/tests/test_dynamics.py b/tests/test_dynamics.py index 881a146e5..700210699 100644 --- a/tests/test_dynamics.py +++ b/tests/test_dynamics.py @@ -21,7 +21,7 @@ def test_max_angular_momentum(self): form_factor_9 = form_factor.subs(angular_momentum, 8).evaluate() factor, z_power, _ = form_factor_9.args assert factor == 4392846440677 - assert z_power == z ** 8 + assert z_power == z**8 assert BlattWeisskopfSquared.max_angular_momentum is None BlattWeisskopfSquared.max_angular_momentum = 1 assert form_factor.evaluate() == sp.Piecewise( @@ -44,9 +44,9 @@ def test_init(): angular_momentum=0, meson_radius=1, ) - assert width.doit() == w0 * sp.sqrt(-(m_a ** 2) + s / 4) * sp.sqrt( - m0 ** 2 - ) / (sp.sqrt(s) * sp.sqrt(m0 ** 2 / 4 - m_a ** 2)) + assert width.doit() == w0 * sp.sqrt(-(m_a**2) + s / 4) * sp.sqrt( + m0**2 + ) / (sp.sqrt(s) * sp.sqrt(m0**2 / 4 - m_a**2)) assert width.phsp_factor is PhaseSpaceFactor assert width._name is None diff --git a/tests/test_kinematics.py b/tests/test_kinematics.py index 586cea6ca..3a6a17bc4 100644 --- a/tests/test_kinematics.py +++ b/tests/test_kinematics.py @@ -328,7 +328,7 @@ def test_compute_invariant_masses( def __compute_mass(array: np.ndarray) -> np.ndarray: energy = array[:, 0] three_momentum = array[:, 1:] - mass_squared = energy ** 2 - np.sum(three_momentum ** 2, axis=1) + mass_squared = energy**2 - np.sum(three_momentum**2, axis=1) return complex_sqrt(mass_squared)