From afa506884c84ccedd497b381830497307e4e794b Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Mon, 12 Feb 2024 22:39:00 +0100 Subject: [PATCH 1/2] DX: do not run notebooks in temp dirs --- pyproject.toml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 7ed59c28..cd26975c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -184,7 +184,11 @@ filterwarnings = [ "ignore:read_text is deprecated.*:DeprecationWarning", "ignore:unclosed .*:ResourceWarning", ] -norecursedirs = ["_build"] +norecursedirs = [ + ".ipynb_checkpoints", + ".virtual_documents", + "_build", +] testpaths = ["docs"] [tool.ruff] From a640241143793d0f3a8ff4b72776e0256f573495 Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Mon, 12 Feb 2024 22:38:59 +0100 Subject: [PATCH 2/2] DX: switch from `black` to ruff --- .gitpod.yml | 1 - .pre-commit-config.yaml | 31 +++++++-------------- .vscode/extensions.json | 2 +- .vscode/settings.json | 3 +-- README.md | 1 - docs/adr/001/sympy.ipynb | 12 +++------ docs/adr/002/composition.ipynb | 4 +-- docs/adr/002/function.ipynb | 5 +--- docs/report/002.ipynb | 4 +-- docs/report/003.ipynb | 13 ++++----- docs/report/005.ipynb | 4 +-- docs/report/009.ipynb | 4 +-- docs/report/010.ipynb | 6 ++--- docs/report/013.ipynb | 4 +-- docs/report/014.ipynb | 13 ++++----- docs/report/015.ipynb | 4 +-- docs/report/016.ipynb | 4 +-- docs/report/017.ipynb | 12 ++------- docs/report/018.ipynb | 8 ++---- docs/report/020.ipynb | 10 +++---- docs/report/021.ipynb | 46 ++++++++----------------------- docs/report/022.ipynb | 4 +-- pyproject.toml | 49 +++++++++++----------------------- 23 files changed, 73 insertions(+), 171 deletions(-) diff --git a/.gitpod.yml b/.gitpod.yml index 7f618730..537fcbbe 100644 --- a/.gitpod.yml +++ b/.gitpod.yml @@ -23,7 +23,6 @@ vscode: - github.vscode-github-actions - github.vscode-pull-request-github - julialang.language-julia - - ms-python.black-formatter - ms-python.python - ms-python.vscode-pylance - ms-toolsai.vscode-jupyter-cell-tags diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9b359669..1f09c2e9 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -39,7 +39,7 @@ repos: metadata.vscode - repo: https://github.com/ComPWA/policy - rev: 0.2.4 + rev: 0.2.5 hooks: - id: check-dev-files args: @@ -55,6 +55,15 @@ repos: - id: pin-nb-requirements - id: set-nb-cells + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.2.1 + hooks: + - id: ruff + args: [--fix] + types_or: [python, pyi, jupyter] + - id: ruff-format + types_or: [python, pyi, jupyter] + - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.5.0 hooks: @@ -80,19 +89,6 @@ repos: .*\.svg )$ - - repo: https://github.com/psf/black-pre-commit-mirror - rev: 24.1.1 - hooks: - - id: black - - id: black-jupyter - args: [--line-length=85] - types_or: [jupyter] - - - repo: https://github.com/asottile/blacken-docs - rev: 1.16.0 - hooks: - - id: blacken-docs - - repo: https://github.com/pre-commit/mirrors-prettier rev: v4.0.0-alpha.8 hooks: @@ -153,10 +149,3 @@ repos: rev: v1.1.350 hooks: - id: pyright - - - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.2.1 - hooks: - - id: ruff - args: [--fix] - types_or: [python, pyi, jupyter] diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 3c823af3..683a4b11 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -9,7 +9,6 @@ "github.vscode-github-actions", "github.vscode-pull-request-github", "julialang.language-julia", - "ms-python.black-formatter", "ms-python.python", "ms-python.vscode-pylance", "ms-toolsai.vscode-jupyter-cell-tags", @@ -26,6 +25,7 @@ "bungcip.better-toml", "davidanson.vscode-markdownlint", "garaioag.garaio-vscode-unwanted-recommendations", + "ms-python.black-formatter", "ms-python.flake8", "ms-python.isort", "ms-python.mypy-type-checker", diff --git a/.vscode/settings.json b/.vscode/settings.json index 04d5e674..9b2cd5dc 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -16,13 +16,12 @@ "editor.codeActionsOnSave": { "source.organizeImports": "explicit" }, - "editor.defaultFormatter": "ms-python.black-formatter", + "editor.defaultFormatter": "charliermarsh.ruff", "editor.rulers": [88] }, "[yaml]": { "editor.defaultFormatter": "esbenp.prettier-vscode" }, - "black-formatter.importStrategy": "fromEnvironment", "cSpell.enabled": true, "diffEditor.experimental.showMoves": true, "editor.formatOnSave": true, diff --git a/README.md b/README.md index 2b08e466..012c8c48 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,6 @@ [![pre-commit.ci status](https://results.pre-commit.ci/badge/github/ComPWA/compwa.github.io/main.svg)](https://results.pre-commit.ci/latest/github/ComPWA/compwa.github.io/main) [![Spelling checked](https://img.shields.io/badge/cspell-checked-brightgreen.svg)](https://github.com/streetsidesoftware/cspell/tree/master/packages/cspell) [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier) -[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff) This repository contains the source code for the [compwa.github.io](https://compwa.github.io) pages. diff --git a/docs/adr/001/sympy.ipynb b/docs/adr/001/sympy.ipynb index 106e77a7..c146c640 100644 --- a/docs/adr/001/sympy.ipynb +++ b/docs/adr/001/sympy.ipynb @@ -506,9 +506,7 @@ "\n", "import sympy as sp\n", "\n", - "x, A1, mu1, sigma1, A2, mu2, sigma2 = sp.symbols(\n", - " \"x, A1, mu1, sigma1, A2, mu2, sigma2\"\n", - ")\n", + "x, A1, mu1, sigma1, A2, mu2, sigma2 = sp.symbols(\"x, A1, mu1, sigma1, A2, mu2, sigma2\")\n", "gaussian1 = (\n", " A1 / (sigma1 * sp.sqrt(2.0 * math.pi)) * sp.exp(-((x - mu1) ** 2) / (2 * sigma1))\n", ")\n", @@ -591,9 +589,7 @@ } ], "source": [ - "numpy_gauss_sum = sp.lambdify(\n", - " (x, A1, mu1, sigma1, A2, mu2, sigma2), gauss_sum, \"numpy\"\n", - ")\n", + "numpy_gauss_sum = sp.lambdify((x, A1, mu1, sigma1, A2, mu2, sigma2), gauss_sum, \"numpy\")\n", "print(inspect.getsource(numpy_gauss_sum))" ] }, @@ -683,9 +679,7 @@ "\n", "\n", "def native_jax_gauss_sum(x_, A1_, mu1_, sigma1_, A2_, mu2_, sigma2_):\n", - " return jax_gaussian(x_, A1_, mu1_, sigma1_) + jax_gaussian(\n", - " x_, A2_, mu2_, sigma2_\n", - " )" + " return jax_gaussian(x_, A1_, mu1_, sigma1_) + jax_gaussian(x_, A2_, mu2_, sigma2_)" ] }, { diff --git a/docs/adr/002/composition.ipynb b/docs/adr/002/composition.ipynb index 03c5ac91..9d5a8531 100644 --- a/docs/adr/002/composition.ipynb +++ b/docs/adr/002/composition.ipynb @@ -131,9 +131,7 @@ " ff02 = blatt_weisskopf(q0_squared, meson_radius, angular_momentum)\n", " width = gamma0 * (mass0 / mass) * (ff2 / ff02)\n", " width = width * sp.sqrt(q_squared / q0_squared)\n", - " return (\n", - " relativistic_breit_wigner(mass, mass0, width) * mass0 * gamma0 * sp.sqrt(ff2)\n", - " )" + " return relativistic_breit_wigner(mass, mass0, width) * mass0 * gamma0 * sp.sqrt(ff2)" ] }, { diff --git a/docs/adr/002/function.ipynb b/docs/adr/002/function.ipynb index 7c9e699c..e1f2e8e2 100644 --- a/docs/adr/002/function.ipynb +++ b/docs/adr/002/function.ipynb @@ -151,10 +151,7 @@ " width = width * sp.sqrt(q_squared / q0_squared)\n", " # Expression\n", " return (\n", - " RelativisticBreitWigner(mass, mass0, width)\n", - " * mass0\n", - " * gamma0\n", - " * sp.sqrt(ff2)\n", + " RelativisticBreitWigner(mass, mass0, width) * mass0 * gamma0 * sp.sqrt(ff2)\n", " )\n", "\n", " @classmethod\n", diff --git a/docs/report/002.ipynb b/docs/report/002.ipynb index 9acd63b5..94b56895 100644 --- a/docs/report/002.ipynb +++ b/docs/report/002.ipynb @@ -837,9 +837,7 @@ "intensity = LambdifiedFunction(sympy_model, backend=\"jax\")\n", "data_converter = HelicityTransformer(model.adapter)\n", "rng = TFUniformRealNumberGenerator(seed=0)\n", - "phsp_sample = generate_phsp(\n", - " 10_000, model.adapter.reaction_info, random_generator=rng\n", - ")\n", + "phsp_sample = generate_phsp(10_000, model.adapter.reaction_info, random_generator=rng)\n", "phsp_set = data_converter.transform(phsp_sample)" ] }, diff --git a/docs/report/003.ipynb b/docs/report/003.ipynb index 824ae95f..1392e4a6 100644 --- a/docs/report/003.ipynb +++ b/docs/report/003.ipynb @@ -705,9 +705,9 @@ "outputs": [], "source": [ "s_thr = (m1 + m2) ** 2\n", - "integrand = (\n", - " PhaseSpaceFactor(s_prime, m1, m2) * FormFactor(s_prime, m1, m2, L, q0)\n", - ") / ((s_prime - s_thr) * (s_prime - s - epsilon * sp.I))\n", + "integrand = (PhaseSpaceFactor(s_prime, m1, m2) * FormFactor(s_prime, m1, m2, L, q0)) / (\n", + " (s_prime - s_thr) * (s_prime - s - epsilon * sp.I)\n", + ")\n", "integrand" ] }, @@ -857,8 +857,7 @@ "outputs": [], "source": [ "sigma = {\n", - " l_val: (s_domain - s_thr_val) / np.pi * integral_values[l_val]\n", - " for l_val in l_values\n", + " l_val: (s_domain - s_thr_val) / np.pi * integral_values[l_val] for l_val in l_values\n", "}\n", "sigma_scaled = {l_val: 16 * np.pi * sigma[l_val] for l_val in l_values}" ] @@ -1185,9 +1184,7 @@ "s_values = np.linspace(-0.15, 1.4, num=200)\n", "fig, axes = plt.subplots(nrows=2, figsize=(6, 7), sharex=True)\n", "ax1, ax2 = axes\n", - "fig.suptitle(\n", - " f\"Symbolic dispersion integrals for $m_1={m1_val:.2f}, m_2={m2_val:.2f}$\"\n", - ")\n", + "fig.suptitle(f\"Symbolic dispersion integrals for $m_1={m1_val:.2f}, m_2={m2_val:.2f}$\")\n", "for ax in axes:\n", " ax.axhline(0, linewidth=0.5, c=\"black\")\n", " ax.axvline(s_thr_val, **threshold_style)\n", diff --git a/docs/report/005.ipynb b/docs/report/005.ipynb index 2c965213..5b312aab 100644 --- a/docs/report/005.ipynb +++ b/docs/report/005.ipynb @@ -449,9 +449,7 @@ ], "source": [ "K_symbol = sp.IndexedBase(\"K\", shape=(n_channels, n_channels))\n", - "K = sp.Matrix(\n", - " [[K_symbol[i, j] for j in range(n_channels)] for i in range(n_channels)]\n", - ")\n", + "K = sp.Matrix([[K_symbol[i, j] for j in range(n_channels)] for i in range(n_channels)])\n", "display(K_symbol[i, j], K)" ] }, diff --git a/docs/report/009.ipynb b/docs/report/009.ipynb index e586310b..16f1589e 100644 --- a/docs/report/009.ipynb +++ b/docs/report/009.ipynb @@ -911,9 +911,7 @@ " c=color,\n", " rotation=+90,\n", " )\n", - " threshold_indicators.append(\n", - " (line_thr, line_diff, text_thr, text_diff)\n", - " )\n", + " threshold_indicators.append((line_thr, line_diff, text_thr, text_diff))\n", " for i, (_, line_diff, _, text_diff) in enumerate(threshold_indicators):\n", " m_a = kwargs[f\"m_a{i}\"]\n", " m_b = kwargs[f\"m_b{i}\"]\n", diff --git a/docs/report/010.ipynb b/docs/report/010.ipynb index 8993a014..419dae57 100644 --- a/docs/report/010.ipynb +++ b/docs/report/010.ipynb @@ -470,9 +470,9 @@ " m = sp.Symbol(\"m\", real=True)\n", " epsilon = sp.Symbol(\"epsilon\", real=True)\n", " i = sp.Symbol(\"i\", integer=True, negative=False)\n", - " expr = f_vector(\n", - " n_resonances, n_channels, angular_momentum=angular_momentum\n", - " ).doit()[i, 0]\n", + " expr = f_vector(n_resonances, n_channels, angular_momentum=angular_momentum).doit()[\n", + " i, 0\n", + " ]\n", " expr = symplot.substitute_indexed_symbols(expr)\n", " expr = expr.subs(m, m + epsilon * sp.I)\n", " np_expr, sliders = symplot.prepare_sliders(expr, m)\n", diff --git a/docs/report/013.ipynb b/docs/report/013.ipynb index dde61b97..1b4b10c1 100644 --- a/docs/report/013.ipynb +++ b/docs/report/013.ipynb @@ -485,9 +485,7 @@ " intensity_func = create_function(substituted_expression, backend=\"jax\")\n", " intensities_all = np.array(intensity_func(phsp).real)\n", " intensities_k = compute_sub_intensities(model, \"K^*\", phsp, full_expression)\n", - " intensities_delta = compute_sub_intensities(\n", - " model, \"Delta^*\", phsp, full_expression\n", - " )\n", + " intensities_delta = compute_sub_intensities(model, \"Delta^*\", phsp, full_expression)\n", " intensities_lambda = compute_sub_intensities(\n", " model, \"Lambda^*\", phsp, full_expression\n", " )\n", diff --git a/docs/report/014.ipynb b/docs/report/014.ipynb index 82ca46be..2e067e93 100644 --- a/docs/report/014.ipynb +++ b/docs/report/014.ipynb @@ -642,8 +642,7 @@ "source": [ "wigner_functions = {\n", " sp.Mul(*[\n", - " formulate_wigner_d(transition, node_id)\n", - " for node_id in transition.topology.nodes\n", + " formulate_wigner_d(transition, node_id) for node_id in transition.topology.nodes\n", " ])\n", " for transition in reaction.transitions\n", "}\n", @@ -985,10 +984,12 @@ "def formulate_intensity_with_coefficient(reaction: ReactionInfo):\n", " amplitudes = {\n", " sp.Mul(\n", - " C[[\n", - " create_helicity_symbol(transition.topology, state_id)\n", - " for state_id in transition.final_states\n", - " ]],\n", + " C[\n", + " [\n", + " create_helicity_symbol(transition.topology, state_id)\n", + " for state_id in transition.final_states\n", + " ]\n", + " ],\n", " *[\n", " formulate_wigner_d(transition, node_id)\n", " for node_id in transition.topology.nodes\n", diff --git a/docs/report/015.ipynb b/docs/report/015.ipynb index bca46d19..147180a8 100644 --- a/docs/report/015.ipynb +++ b/docs/report/015.ipynb @@ -557,9 +557,7 @@ " particle_name = state.particle.latex\n", " s = sp.Rational(state.particle.spin)\n", " m = sp.Rational(state.spin_projection)\n", - " display(\n", - " Math(Rf\"|s_{i},m_{i}\\rangle=|{s},{m}\\rangle \\quad ({particle_name})\")\n", - " )\n", + " display(Math(Rf\"|s_{i},m_{i}\\rangle=|{s},{m}\\rangle \\quad ({particle_name})\"))\n", " if functor is formulate_rotation_chain:\n", " args = (transition, i)\n", " else:\n", diff --git a/docs/report/016.ipynb b/docs/report/016.ipynb index 3f2f6ddd..30f50cce 100644 --- a/docs/report/016.ipynb +++ b/docs/report/016.ipynb @@ -600,9 +600,7 @@ "outputs": [], "source": [ "func = sp.lambdify([x, omega1, omega2, phi1, phi2], expr.doit())\n", - "fourier_func = sp.lambdify(\n", - " [w, omega1, omega2, phi1, phi2, a, b], fourier_expr.doit()\n", - ")" + "fourier_func = sp.lambdify([w, omega1, omega2, phi1, phi2, a, b], fourier_expr.doit())" ] }, { diff --git a/docs/report/017.ipynb b/docs/report/017.ipynb index 9585cb7b..216520c3 100644 --- a/docs/report/017.ipynb +++ b/docs/report/017.ipynb @@ -208,9 +208,7 @@ "@implement_doit_method\n", "class Kibble(UnevaluatedExpression):\n", " def __new__(cls, sigma1, sigma2, sigma3, m0, m1, m2, m3, **hints) -> Kibble:\n", - " return create_expression(\n", - " cls, sigma1, sigma2, sigma3, m0, m1, m2, m3, **hints\n", - " )\n", + " return create_expression(cls, sigma1, sigma2, sigma3, m0, m1, m2, m3, **hints)\n", "\n", " def evaluate(self) -> sp.Expr:\n", " sigma1, sigma2, sigma3, m0, m1, m2, m3 = self.args\n", @@ -609,13 +607,7 @@ " T2: T0 / 3 - r * sp.cos(theta + 2 * sp.pi / 3),\n", " T3: T0 / 3 - r * sp.cos(theta + 4 * sp.pi / 3),\n", " T0: (\n", - " m0**2\n", - " + m1**2\n", - " + m2**2\n", - " + m3**2\n", - " - (m2 + m3) ** 2\n", - " - (m1 + m3) ** 2\n", - " - (m1 + m2) ** 2\n", + " m0**2 + m1**2 + m2**2 + m3**2 - (m2 + m3) ** 2 - (m1 + m3) ** 2 - (m1 + m2) ** 2\n", " ),\n", "}" ] diff --git a/docs/report/018.ipynb b/docs/report/018.ipynb index 3b26cae3..5abf83f1 100644 --- a/docs/report/018.ipynb +++ b/docs/report/018.ipynb @@ -213,9 +213,7 @@ " initial_state_mass=reaction.initial_state[-1].mass,\n", " final_state_masses={i: p.mass for i, p in reaction.final_state.items()},\n", ")\n", - "transformer = SympyDataTransformer.from_sympy(\n", - " model.kinematic_variables, backend=\"jax\"\n", - ")\n", + "transformer = SympyDataTransformer.from_sympy(model.kinematic_variables, backend=\"jax\")\n", "phsp = phsp_generator.generate(1_000_000, rng)\n", "phsp = transformer(phsp)" ] @@ -350,9 +348,7 @@ "\n", " Z_weights = griddata(np.transpose([x, y]), weights, (X, Y))\n", " Z_unweighted, x_edges, y_edges = jnp.histogram2d(x, y, bins=n_bins)\n", - " Z_weighted, x_edges, y_edges = jnp.histogram2d(\n", - " x, y, bins=n_bins, weights=weights\n", - " )\n", + " Z_weighted, x_edges, y_edges = jnp.histogram2d(x, y, bins=n_bins, weights=weights)\n", " # https://numpy.org/doc/stable/reference/generated/numpy.histogram2d.html\n", " Z_unweighted = Z_unweighted.T\n", " Z_weighted = Z_weighted.T\n", diff --git a/docs/report/020.ipynb b/docs/report/020.ipynb index 4df0cfe4..129eb57a 100644 --- a/docs/report/020.ipynb +++ b/docs/report/020.ipynb @@ -810,9 +810,7 @@ ], "source": [ "minuit2 = Minuit2()\n", - "fit_result_with_caching = minuit2.optimize(\n", - " estimator_with_caching, initial_parameters\n", - ")\n", + "fit_result_with_caching = minuit2.optimize(estimator_with_caching, initial_parameters)\n", "fit_result_with_caching" ] }, @@ -920,9 +918,9 @@ " # this here is rather to take full control, it is always possible\n", "\n", " # updating the parameters of the model. This seems not very TF compatible?\n", - " self.intensity.update_parameters(\n", - " {p.name: float(p) for p in self.params.values()}\n", - " )\n", + " self.intensity.update_parameters({\n", + " p.name: float(p) for p in self.params.values()\n", + " })\n", "\n", " # converting the data to a dict for tensorwaves\n", " data = {ob: jnp.asarray(ar) for ob, ar in zip(self.obs, z.unstack_x(x))}\n", diff --git a/docs/report/021.ipynb b/docs/report/021.ipynb index 1f6c5943..b270b447 100644 --- a/docs/report/021.ipynb +++ b/docs/report/021.ipynb @@ -509,9 +509,7 @@ " _ν = sp.Symbol(R\"\\nu^{\\prime}\", rational=True)\n", " _λ = sp.Symbol(R\"\\lambda^{\\prime}\", rational=True)\n", " return PoolSum(\n", - " A_K[_ν, _λ]\n", - " * Wigner.d(half, λ_Λc, _ν, ζ_0_11)\n", - " * Wigner.d(half, _λ, λ_p, ζ_1_11)\n", + " A_K[_ν, _λ] * Wigner.d(half, λ_Λc, _ν, ζ_0_11) * Wigner.d(half, _λ, λ_p, ζ_1_11)\n", " + A_Λ[_ν, _λ]\n", " * Wigner.d(half, λ_Λc, _ν, ζ_0_21)\n", " * Wigner.d(half, _λ, λ_p, ζ_1_21)\n", @@ -638,9 +636,9 @@ " 1: 1 / (1 + z**2),\n", " 2: 1 / (9 + 3 * z**2 + z**4),\n", " }\n", - " return sp.Piecewise(\n", - " *[(sp.sqrt(expr), sp.Eq(L, l_val)) for l_val, expr in cases.items()]\n", - " )\n", + " return sp.Piecewise(*[\n", + " (sp.sqrt(expr), sp.Eq(L, l_val)) for l_val, expr in cases.items()\n", + " ])\n", "\n", " def _latex(self, printer, *args):\n", " z, L = map(printer._print, self.args)\n", @@ -1148,32 +1146,20 @@ " ),\n", " ζ_0_11: sp.S.Zero, # = \\hat\\theta^0_{1(1)}\n", " ζ_0_21: -sp.acos( # = -\\hat\\theta^{1(2)}\n", - " (\n", - " (m0**2 + m1**2 - σ1) * (m0**2 + m2**2 - σ2)\n", - " - 2 * m0**2 * (σ3 - m1**2 - m2**2)\n", - " )\n", + " ((m0**2 + m1**2 - σ1) * (m0**2 + m2**2 - σ2) - 2 * m0**2 * (σ3 - m1**2 - m2**2))\n", " / (sp.sqrt(Källén(m0**2, m2**2, σ2)) * sp.sqrt(Källén(m0**2, σ1, m1**2)))\n", " ),\n", " ζ_0_31: sp.acos( # = \\hat\\theta^{3(1)}\n", - " (\n", - " (m0**2 + m3**2 - σ3) * (m0**2 + m1**2 - σ1)\n", - " - 2 * m0**2 * (σ2 - m3**2 - m1**2)\n", - " )\n", + " ((m0**2 + m3**2 - σ3) * (m0**2 + m1**2 - σ1) - 2 * m0**2 * (σ2 - m3**2 - m1**2))\n", " / (sp.sqrt(Källén(m0**2, m1**2, σ1)) * sp.sqrt(Källén(m0**2, σ3, m3**2)))\n", " ),\n", " ζ_1_11: sp.S.Zero,\n", " ζ_1_21: sp.acos(\n", - " (\n", - " 2 * m1**2 * (σ3 - m0**2 - m3**2)\n", - " + (m0**2 + m1**2 - σ1) * (σ2 - m1**2 - m3**2)\n", - " )\n", + " (2 * m1**2 * (σ3 - m0**2 - m3**2) + (m0**2 + m1**2 - σ1) * (σ2 - m1**2 - m3**2))\n", " / (sp.sqrt(Källén(m0**2, m1**2, σ1)) * sp.sqrt(Källén(σ2, m1**2, m3**2)))\n", " ),\n", " ζ_1_31: -sp.acos( # = -\\zeta^1_{1(3)}\n", - " (\n", - " 2 * m1**2 * (σ2 - m0**2 - m2**2)\n", - " + (m0**2 + m1**2 - σ1) * (σ3 - m1**2 - m2**2)\n", - " )\n", + " (2 * m1**2 * (σ2 - m0**2 - m2**2) + (m0**2 + m1**2 - σ1) * (σ3 - m1**2 - m2**2))\n", " / (sp.sqrt(Källén(m0**2, m1**2, σ1)) * sp.sqrt(Källén(σ3, m1**2, m2**2)))\n", " ),\n", "}\n", @@ -2347,16 +2333,8 @@ "for res_list in resonance_particles.values():\n", " for res in res_list:\n", " coupling_sliders[res.name] = (\n", - " [\n", - " s\n", - " for n, s in sliders.items()\n", - " if n.endswith(\"_real\") and res.latex in n\n", - " ],\n", - " [\n", - " s\n", - " for n, s in sliders.items()\n", - " if n.endswith(\"_imag\") and res.latex in n\n", - " ],\n", + " [s for n, s in sliders.items() if n.endswith(\"_real\") and res.latex in n],\n", + " [s for n, s in sliders.items() if n.endswith(\"_imag\") and res.latex in n],\n", " [\n", " HTMLMath(f\"${latex[n[:-5]]}$\")\n", " for n in sliders\n", @@ -2438,9 +2416,7 @@ " else:\n", " mesh.set_array(intensity)\n", " if quiver is None:\n", - " quiver = ax2.quiver(\n", - " Xα, Yα, αx, αz, abs_α, cmap=plt.cm.viridis_r, clim=(0, 1)\n", - " )\n", + " quiver = ax2.quiver(Xα, Yα, αx, αz, abs_α, cmap=plt.cm.viridis_r, clim=(0, 1))\n", " c_bar = fig.colorbar(quiver, ax=ax2, pad=0.01, fraction=0.0473)\n", " c_bar.ax.set_ylabel(R\"$\\left|\\vec\\alpha\\right|$\")\n", " else:\n", diff --git a/docs/report/022.ipynb b/docs/report/022.ipynb index 29f183ff..c9c71a1d 100644 --- a/docs/report/022.ipynb +++ b/docs/report/022.ipynb @@ -419,9 +419,7 @@ } ], "source": [ - "B_arrays = jnp.array(\n", - " [[B_funcs[τ, ρ](GRID_SAMPLE) for ρ in range(4)] for τ in range(4)]\n", - ")\n", + "B_arrays = jnp.array([[B_funcs[τ, ρ](GRID_SAMPLE) for ρ in range(4)] for τ in range(4)])\n", "B_norm = B_arrays / B_arrays[0, 0]\n", "B_arrays.shape" ] diff --git a/pyproject.toml b/pyproject.toml index cd26975c..39581b84 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -63,9 +63,8 @@ doc = [ "sphinx-togglebutton", "sphinxcontrib-bibtex >=2", ] -format = ["black"] jupyter = [ - "compwa-org[doc]", + "black", "isort", "jupyterlab", "jupyterlab-code-formatter", @@ -76,20 +75,21 @@ jupyter = [ "python-lsp-server[rope]", 'ypy-websocket <0.8.3; python_version <"3.8.0"', ] -lint = ["ruff"] sty = [ - "attrs", # https://github.com/ComPWA/compwa.github.io/runs/8127821070?check_suite_focus=true#step:5:52 - "compwa-org[format]", - "compwa-org[lint]", - "nbformat", + "compwa-org[types]", "pre-commit >=1.4.0", - "sphinx-api-relink >=0.0.4", + "ruff", ] test = [ "jupyter", "nbmake", 'nbmake <1.3; python_version=="3.7.*"', ] +types = [ + "attrs", + "nbformat", + "sphinx-api-relink >=0.0.4", +] [project.readme] content-type = "text/markdown" @@ -106,31 +106,6 @@ include-package-data = false [tool.setuptools_scm] write_to = "version.py" -[tool.black] -exclude = ''' -/( - .*\.egg-info - | .*build - | \.eggs - | \.git - | \.pytest_cache - | \.tox - | \.venv - | \.vscode - | dist -)/ -''' -include = '\.pyi?$' -preview = true -target-version = [ - "py310", - "py311", - "py312", - "py37", - "py38", - "py39", -] - [tool.pyright] exclude = [ "**/.git", @@ -146,6 +121,7 @@ reportIncompatibleMethodOverride = false reportMissingParameterType = false reportMissingTypeArgument = false reportMissingTypeStubs = false +reportOperatorIssue = false reportOverlappingOverload = false reportPrivateImportUsage = false reportPrivateUsage = false @@ -197,6 +173,10 @@ preview = true show-fixes = true target-version = "py37" +[tool.ruff.format] +docstring-code-format = true +line-ending = "lf" + [tool.ruff.lint] extend-select = [ "A", @@ -241,6 +221,7 @@ ignore = [ "D407", "D416", "E501", + "ISC001", "PLW1514", "SIM108", ] @@ -250,7 +231,7 @@ task-tags = ["cspell"] split-on-trailing-comma = false [tool.ruff.lint.per-file-ignores] -"**/003.ipynb" = ["B023", "PLC2701"] # conflict with black-jupyter +"**/003.ipynb" = ["B023", "PLC2701"] "**/011.ipynb" = ["PLC2701", "PLR6301"] "**/014.ipynb" = ["PLC2701"] "**/016.ipynb" = ["PLC2701"]