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 Nov 8, 2023
1 parent 8f04207 commit 4dff7a9
Show file tree
Hide file tree
Showing 16 changed files with 392 additions and 479 deletions.
58 changes: 26 additions & 32 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,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
)

Expand Down Expand Up @@ -157,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 = {
Expand Down
82 changes: 35 additions & 47 deletions docs/usage/dynamics/k-matrix.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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)"
]
},
{
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
22 changes: 10 additions & 12 deletions docs/usage/interactive.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
"})"
]
},
{
Expand Down
12 changes: 5 additions & 7 deletions docs/usage/kinematics.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
]
},
Expand Down
13 changes: 5 additions & 8 deletions src/ampform/dynamics/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,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))
Expand Down
Loading

0 comments on commit 4dff7a9

Please sign in to comment.