Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jul 4, 2023
1 parent 508ac7b commit aa73516
Show file tree
Hide file tree
Showing 18 changed files with 299 additions and 179 deletions.
6 changes: 5 additions & 1 deletion docs/_relink_references.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,15 @@
"""
from __future__ import annotations

from typing import TYPE_CHECKING

import sphinx.domains.python
from docutils import nodes
from sphinx.addnodes import pending_xref, pending_xref_condition
from sphinx.domains.python import parse_reftarget
from sphinx.environment import BuildEnvironment

if TYPE_CHECKING:
from sphinx.environment import BuildEnvironment

__TARGET_SUBSTITUTIONS = {
"Literal[- 1, 1]": "typing.Literal",
Expand Down
15 changes: 11 additions & 4 deletions docs/_unsrt_et_al.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
from pybtex.database import Entry
from pybtex.richtext import Tag, Text
from pybtex.style.formatting.unsrt import Style as UnsrtStyle
from pybtex.style.template import \
_format_list # pyright: ignore[reportPrivateUsage]
from pybtex.style.template import (FieldIsMissing, Node, field, href, join,
node, sentence, words)
from pybtex.style.template import (
FieldIsMissing,
Node,
_format_list, # pyright: ignore[reportPrivateUsage]
field,
href,
join,
node,
sentence,
words,
)


class MyStyle(UnsrtStyle): # type: ignore[reportUntypedBaseClass]
Expand Down
69 changes: 44 additions & 25 deletions docs/comparison/d2kkk.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"import logging\n",
"import os\n",
"from textwrap import dedent\n",
"from typing import Iterable\n",
"from typing import TYPE_CHECKING, Iterable\n",
"\n",
"import ampform\n",
"import graphviz\n",
Expand All @@ -44,28 +44,49 @@
"import matplotlib.pyplot as plt\n",
"import qrules\n",
"import sympy as sp\n",
"from ampform.helicity import HelicityModel\n",
"from ampform.kinematics import FourMomentumSymbol, InvariantMass\n",
"from ampform.sympy import perform_cached_doit\n",
"from IPython.display import SVG, Latex, Markdown, clear_output, display\n",
"from ipywidgets import (Accordion, Checkbox, GridBox, HBox, Layout,\n",
" SelectMultiple, Tab, ToggleButtons, VBox,\n",
" interactive_output)\n",
"from qrules.transition import ReactionInfo\n",
"from ipywidgets import (\n",
" Accordion,\n",
" Checkbox,\n",
" GridBox,\n",
" HBox,\n",
" Layout,\n",
" SelectMultiple,\n",
" Tab,\n",
" ToggleButtons,\n",
" VBox,\n",
" interactive_output,\n",
")\n",
"from tensorwaves.data.phasespace import TFPhaseSpaceGenerator\n",
"from tensorwaves.data.rng import TFUniformRealNumberGenerator\n",
"from tensorwaves.data.transform import SympyDataTransformer\n",
"from tensorwaves.interface import (DataSample, ParameterValue,\n",
" ParametrizedFunction)\n",
"\n",
"from ampform_dpd import (DalitzPlotDecompositionBuilder,\n",
" simplify_latex_rendering)\n",
"from ampform_dpd.decay import (IsobarNode, Particle, ThreeBodyDecay,\n",
" ThreeBodyDecayChain)\n",
"from ampform_dpd.io import (as_markdown_table, aslatex, get_readable_hash,\n",
" perform_cached_lambdify)\n",
"\n",
"from ampform_dpd import DalitzPlotDecompositionBuilder, simplify_latex_rendering\n",
"from ampform_dpd.decay import (\n",
" IsobarNode,\n",
" Particle,\n",
" ThreeBodyDecay,\n",
" ThreeBodyDecayChain,\n",
")\n",
"from ampform_dpd.io import (\n",
" as_markdown_table,\n",
" aslatex,\n",
" get_readable_hash,\n",
" perform_cached_lambdify,\n",
")\n",
"from ampform_dpd.spin import filter_parity_violating_ls, generate_ls_couplings\n",
"\n",
"if TYPE_CHECKING:\n",
" from ampform.helicity import HelicityModel\n",
" from qrules.transition import ReactionInfo\n",
" from tensorwaves.interface import (\n",
" DataSample,\n",
" ParameterValue,\n",
" ParametrizedFunction,\n",
" )\n",
"\n",
"simplify_latex_rendering()\n",
"logging.getLogger(\"jax\").setLevel(logging.ERROR) # mute JAX\n",
"os.environ[\"TF_CPP_MIN_LOG_LEVEL\"] = \"3\" # mute TF\n",
Expand Down Expand Up @@ -628,17 +649,16 @@
"outputs": [],
"source": [
"def create_sliders() -> dict[str, ToggleButtons]:\n",
" all_parameters = {k: v for k, v in ampform_model.parameter_defaults.items()}\n",
" all_parameters.update({k: v for k, v in dpd_model.parameter_defaults.items()})\n",
" all_parameters = dict(ampform_model.parameter_defaults.items())\n",
" all_parameters.update(dict(dpd_model.parameter_defaults.items()))\n",
" sliders = {}\n",
" for symbol, value in all_parameters.items():\n",
" value = \"+1\"\n",
" if (\n",
" symbol.name.startswith(R\"\\mathcal{H}^\\mathrm{decay}\")\n",
" and \"+\" in symbol.name\n",
" ):\n",
" if any(s in symbol.name for s in [\"{1}\", \"*\", \"rho\"]):\n",
" value = \"-1\"\n",
" ) and any(s in symbol.name for s in [\"{1}\", \"*\", \"rho\"]):\n",
" value = \"-1\"\n",
" sliders[symbol.name] = ToggleButtons(\n",
" description=Rf\"\\({sp.latex(symbol)}\\)\",\n",
" options=[\"-1\", \"0\", \"+1\"],\n",
Expand All @@ -651,16 +671,15 @@
"def to_unicode(particle: Particle) -> str:\n",
" unicode = particle.name\n",
" unicode = unicode.replace(\"pi\", \"π\")\n",
" unicode = unicode.replace(\"rho\", \"ρ\")\n",
" unicode = unicode.replace(\"rho\", \"p\")\n",
" unicode = unicode.replace(\"Sigma\", \"Σ\")\n",
" unicode = unicode.replace(\"~\", \"\")\n",
" unicode = unicode.replace(\"Σ\", \"\")\n",
" unicode = unicode.replace(\"+\", \"\")\n",
" unicode = unicode.replace(\"-\", \"\")\n",
" unicode = unicode.replace(\"(0)\", \"\")\n",
" unicode = unicode.replace(\"(1)\", \"\")\n",
" unicode = unicode.replace(\")0\", \")⁰\")\n",
" return unicode\n",
" return unicode.replace(\")0\", \")⁰\")\n",
"\n",
"\n",
"sliders = create_sliders()\n",
Expand Down Expand Up @@ -880,8 +899,8 @@
" )\n",
"\n",
" global lines\n",
" amp_kwargs = dict(color=\"r\", label=\"ampform\", linestyle=\"solid\")\n",
" dpd_kwargs = dict(color=\"blue\", label=\"dpd\", linestyle=\"dotted\")\n",
" amp_kwargs = {\"color\": \"r\", \"label\": \"ampform\", \"linestyle\": \"solid\"}\n",
" dpd_kwargs = {\"color\": \"blue\", \"label\": \"dpd\", \"linestyle\": \"dotted\"}\n",
" if lines is None:\n",
" sx = (s_edges[:-1] + s_edges[1:]) / 2\n",
" tx = (t_edges[:-1] + t_edges[1:]) / 2\n",
Expand Down
69 changes: 44 additions & 25 deletions docs/comparison/jpsi2phipipi.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"import logging\n",
"import os\n",
"from textwrap import dedent\n",
"from typing import Iterable\n",
"from typing import TYPE_CHECKING, Iterable\n",
"\n",
"import ampform\n",
"import graphviz\n",
Expand All @@ -44,28 +44,49 @@
"import matplotlib.pyplot as plt\n",
"import qrules\n",
"import sympy as sp\n",
"from ampform.helicity import HelicityModel\n",
"from ampform.kinematics import FourMomentumSymbol, InvariantMass\n",
"from ampform.sympy import perform_cached_doit\n",
"from IPython.display import SVG, Latex, Markdown, clear_output, display\n",
"from ipywidgets import (Accordion, Checkbox, GridBox, HBox, Layout,\n",
" SelectMultiple, Tab, ToggleButtons, VBox,\n",
" interactive_output)\n",
"from qrules.transition import ReactionInfo\n",
"from ipywidgets import (\n",
" Accordion,\n",
" Checkbox,\n",
" GridBox,\n",
" HBox,\n",
" Layout,\n",
" SelectMultiple,\n",
" Tab,\n",
" ToggleButtons,\n",
" VBox,\n",
" interactive_output,\n",
")\n",
"from tensorwaves.data.phasespace import TFPhaseSpaceGenerator\n",
"from tensorwaves.data.rng import TFUniformRealNumberGenerator\n",
"from tensorwaves.data.transform import SympyDataTransformer\n",
"from tensorwaves.interface import (DataSample, ParameterValue,\n",
" ParametrizedFunction)\n",
"\n",
"from ampform_dpd import (DalitzPlotDecompositionBuilder,\n",
" simplify_latex_rendering)\n",
"from ampform_dpd.decay import (IsobarNode, Particle, ThreeBodyDecay,\n",
" ThreeBodyDecayChain)\n",
"from ampform_dpd.io import (as_markdown_table, aslatex, get_readable_hash,\n",
" perform_cached_lambdify)\n",
"\n",
"from ampform_dpd import DalitzPlotDecompositionBuilder, simplify_latex_rendering\n",
"from ampform_dpd.decay import (\n",
" IsobarNode,\n",
" Particle,\n",
" ThreeBodyDecay,\n",
" ThreeBodyDecayChain,\n",
")\n",
"from ampform_dpd.io import (\n",
" as_markdown_table,\n",
" aslatex,\n",
" get_readable_hash,\n",
" perform_cached_lambdify,\n",
")\n",
"from ampform_dpd.spin import filter_parity_violating_ls, generate_ls_couplings\n",
"\n",
"if TYPE_CHECKING:\n",
" from ampform.helicity import HelicityModel\n",
" from qrules.transition import ReactionInfo\n",
" from tensorwaves.interface import (\n",
" DataSample,\n",
" ParameterValue,\n",
" ParametrizedFunction,\n",
" )\n",
"\n",
"simplify_latex_rendering()\n",
"logging.getLogger(\"jax\").setLevel(logging.ERROR) # mute JAX\n",
"os.environ[\"TF_CPP_MIN_LOG_LEVEL\"] = \"3\" # mute TF\n",
Expand Down Expand Up @@ -611,17 +632,16 @@
"outputs": [],
"source": [
"def create_sliders() -> dict[str, ToggleButtons]:\n",
" all_parameters = {k: v for k, v in ampform_model.parameter_defaults.items()}\n",
" all_parameters.update({k: v for k, v in dpd_model.parameter_defaults.items()})\n",
" all_parameters = dict(ampform_model.parameter_defaults.items())\n",
" all_parameters.update(dict(dpd_model.parameter_defaults.items()))\n",
" sliders = {}\n",
" for symbol, value in all_parameters.items():\n",
" value = \"+1\"\n",
" if (\n",
" symbol.name.startswith(R\"\\mathcal{H}^\\mathrm{decay}\")\n",
" and \"+\" in symbol.name\n",
" ):\n",
" if any(s in symbol.name for s in [\"{1}\", \"*\", \"rho\"]):\n",
" value = \"-1\"\n",
" ) and any(s in symbol.name for s in [\"{1}\", \"*\", \"rho\"]):\n",
" value = \"-1\"\n",
" sliders[symbol.name] = ToggleButtons(\n",
" description=Rf\"\\({sp.latex(symbol)}\\)\",\n",
" options=[\"-1\", \"0\", \"+1\"],\n",
Expand All @@ -634,16 +654,15 @@
"def to_unicode(particle: Particle) -> str:\n",
" unicode = particle.name\n",
" unicode = unicode.replace(\"pi\", \"π\")\n",
" unicode = unicode.replace(\"rho\", \"ρ\")\n",
" unicode = unicode.replace(\"rho\", \"p\")\n",
" unicode = unicode.replace(\"Sigma\", \"Σ\")\n",
" unicode = unicode.replace(\"~\", \"\")\n",
" unicode = unicode.replace(\"Σ\", \"\")\n",
" unicode = unicode.replace(\"+\", \"\")\n",
" unicode = unicode.replace(\"-\", \"\")\n",
" unicode = unicode.replace(\"(0)\", \"\")\n",
" unicode = unicode.replace(\"(1)\", \"\")\n",
" unicode = unicode.replace(\")0\", \")⁰\")\n",
" return unicode\n",
" return unicode.replace(\")0\", \")⁰\")\n",
"\n",
"\n",
"sliders = create_sliders()\n",
Expand Down Expand Up @@ -864,8 +883,8 @@
" )\n",
"\n",
" global lines\n",
" amp_kwargs = dict(color=\"r\", label=\"ampform\", linestyle=\"solid\")\n",
" dpd_kwargs = dict(color=\"blue\", label=\"dpd\", linestyle=\"dotted\")\n",
" amp_kwargs = {\"color\": \"r\", \"label\": \"ampform\", \"linestyle\": \"solid\"}\n",
" dpd_kwargs = {\"color\": \"blue\", \"label\": \"dpd\", \"linestyle\": \"dotted\"}\n",
" if lines is None:\n",
" sx1 = (s1_edges[:-1] + s1_edges[1:]) / 2\n",
" sx23 = (s23_edges[:-1] + s23_edges[1:]) / 2\n",
Expand Down
Loading

0 comments on commit aa73516

Please sign in to comment.