diff --git a/.github/workflows/clean-caches.yml b/.github/workflows/clean-caches.yml new file mode 100644 index 0000000..a66c407 --- /dev/null +++ b/.github/workflows/clean-caches.yml @@ -0,0 +1,22 @@ +name: Clean caches + +on: + pull_request: + types: + - closed + workflow_dispatch: + inputs: + ref: + description: Clean caches for this branch name or ref + required: false + type: string + +jobs: + cleanup: + name: Remove caches + runs-on: ubuntu-22.04 + steps: + - uses: ComPWA/actions/clean-caches@v1 + with: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + ref: ${{ inputs.ref }} diff --git a/.github/workflows/pr-linting.yml b/.github/workflows/pr-linting.yml new file mode 100644 index 0000000..cd3bb74 --- /dev/null +++ b/.github/workflows/pr-linting.yml @@ -0,0 +1,33 @@ +name: PR linting +on: + pull_request: + types: + - edited + - labeled + - opened + - reopened + - synchronize + - unlabeled + +jobs: + check-labels: + name: Check labels + runs-on: ubuntu-22.04 + steps: + - uses: docker://agilepathway/pull-request-label-checker:latest # cspell:ignore agilepathway + with: + any_of: >- + 🐛 Bug,✨ Feature,⚙ī¸ Enhancement,⚠ī¸ Interface,❗ Behavior,📝 Docs,🔨 Maintenance,🖱ī¸ DX + none_of: Epic,đŸ’Ģ Good first issue + repo_token: ${{ secrets.GITHUB_TOKEN }} + + check-title: + name: Check title + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + - run: npm install @compwa/commitlint-config + - name: Create commitlint config + run: | + echo "module.exports = {extends: ['@compwa/commitlint-config']}" > commitlint.config.js + - uses: JulienKode/pull-request-name-linter-action@v0.5.0 # cspell:ignore kode diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c7c0d4b..b304805 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,7 +5,7 @@ repos: - id: check-useless-excludes - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: v4.5.0 hooks: - id: check-case-conflict - id: check-json @@ -14,15 +14,43 @@ repos: - id: mixed-line-ending - id: trailing-whitespace + - repo: https://github.com/psf/black + rev: 23.9.1 + hooks: + - id: black-jupyter + args: [--line-length=85] + types_or: [jupyter] + + - repo: https://github.com/ComPWA/repo-maintenance + rev: 0.1.0 + hooks: + - id: check-dev-files + args: + - --ignore-author + - --no-github-actions + - --no-gitpod + - --no-prettierrc + - --no-python + - --no-ruff + - --no-version-branches + - --repo-name=strong2020-salamanca + - id: colab-toc-visible + - repo: https://github.com/nbQA-dev/nbQA rev: 1.7.0 hooks: - - id: nbqa-black - id: nbqa-flake8 - id: nbqa-isort - id: nbqa-pyupgrade args: [--py37-plus] + - repo: https://github.com/editorconfig-checker/editorconfig-checker.python + rev: 2.7.2 + hooks: + - id: editorconfig-checker + name: editorconfig + alias: ec + - repo: https://github.com/kynan/nbstripout rev: 0.6.1 hooks: @@ -31,16 +59,13 @@ repos: - --extra-keys - | cell.attachments - cell.id cell.metadata.code_folding - cell.metadata.colab - cell.metadata.editable - cell.metadata.executionInfo cell.metadata.id - cell.metadata.outputId + cell.metadata.pycharm cell.metadata.user_expressions metadata.celltoolbar - metadata.colab + metadata.colab.name + metadata.colab.provenance metadata.interpreter metadata.notify_time metadata.toc diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 35779c0..8c7aa0c 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -4,6 +4,7 @@ "editorconfig.editorconfig", "esbenp.prettier-vscode", "executablebookproject.myst-highlight", + "garaioag.garaio-vscode-unwanted-recommendations", "github.vscode-github-actions", "github.vscode-pull-request-github", "mhutchie.git-graph", @@ -12,7 +13,13 @@ "ms-toolsai.vscode-jupyter-cell-tags", "ms-toolsai.vscode-jupyter-slideshow", "ms-vscode.live-server", + "stkb.rewrap", "tyriar.sort-lines", "yzhang.markdown-all-in-one" + ], + "unwantedRecommendations": [ + "davidanson.vscode-markdownlint", + "ms-python.mypy-type-checker", + "travisillig.vscode-json-stable-stringify" ] } diff --git a/.vscode/settings.json b/.vscode/settings.json index ad92582..c293661 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,10 @@ { - "editor.formatOnSave": true + "[git-commit]": { + "editor.rulers": [72], + "rewrap.wrappingColumn": 72 + }, + "editor.formatOnSave": true, + "livePreview.defaultPreviewPath": "docs/_build/html", + "notebook.gotoSymbols.showAllSymbols": true, + "rewrap.wrappingColumn": 88 } diff --git a/README.md b/README.md index 0fc5f8d..e9ca859 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ # STRONG2020 HaSP School +[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier) [![Google Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/ComPWA/strong2020-salamanca/blob/main) [![GitHub Pages](https://github.com/ComPWA/strong2020-salamanca/actions/workflows/docs.yml/badge.svg)](https://github.com/ComPWA/strong2020-salamanca/actions/workflows/docs.yml) @@ -13,7 +14,7 @@ This (unofficial) repository contains the exercises for the [STRONG2020 HaSP Sch ```shell conda env create - conda activate strong2020 + conda activate strong2020-salamanca ``` 3. Run notebooks in [Jupyter Lab](https://jupyter.org): diff --git a/docs/lecture02.ipynb b/docs/lecture02.ipynb index 10ce991..1c62bf8 100644 --- a/docs/lecture02.ipynb +++ b/docs/lecture02.ipynb @@ -543,6 +543,9 @@ } ], "metadata": { + "colab": { + "toc_visible": true + }, "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", diff --git a/docs/lecture06-gammap.ipynb b/docs/lecture06-gammap.ipynb index 42a4fdc..5fd7dc8 100644 --- a/docs/lecture06-gammap.ipynb +++ b/docs/lecture06-gammap.ipynb @@ -667,7 +667,9 @@ "fig = plt.figure()\n", "x_hist_2 = np.linspace(np.min(x_hist), np.max(x_hist), 100)\n", "# this plots the curve only\n", - "plt.plot(x_hist_2, gaus(x_hist_2, *param_optimised), color=\"red\", label=\"Gaussian fit\")\n", + "plt.plot(\n", + " x_hist_2, gaus(x_hist_2, *param_optimised), color=\"red\", label=\"Gaussian fit\"\n", + ")\n", "plt.legend()\n", "\n", "# plot the experimental point of the portion of spectrum to be fitted\n", @@ -779,7 +781,9 @@ "fig = plt.figure()\n", "x_hist_2 = np.linspace(np.min(x_hist), np.max(x_hist), 100)\n", "# this plots the curve only\n", - "plt.plot(x_hist_2, gaus(x_hist_2, *param_optimised), color=\"red\", label=\"Gaussian fit\")\n", + "plt.plot(\n", + " x_hist_2, gaus(x_hist_2, *param_optimised), color=\"red\", label=\"Gaussian fit\"\n", + ")\n", "plt.legend()\n", "\n", "# plot the experimental point of the portion of spectrum to be fitted\n", @@ -914,7 +918,10 @@ "x_hist_2 = np.linspace(np.min(x_hist), np.max(x_hist), 100)\n", "# this plots the curve only\n", "ax[0].plot(\n", - " x_hist_2, gausAndBCK(x_hist_2, *param_optimised), color=\"red\", label=\"Gaussian fit\"\n", + " x_hist_2,\n", + " gausAndBCK(x_hist_2, *param_optimised),\n", + " color=\"red\",\n", + " label=\"Gaussian fit\",\n", ")\n", "ax[0].plot(x_hist_2, gaus(x_hist_2, *param_optimised_gauss), color=\"cyan\")\n", "ax[0].plot(x_hist_2, BCK(x_hist_2, *param_optimised_bck), color=\"magenta\")\n", @@ -979,7 +986,9 @@ "# normalize the histogram to 1\n", "low_edge = 0.8\n", "up_edge = 1.0\n", - "hist, bin_edges = np.histogram(missingMomentumDipion.m2, 100, range=(low_edge, up_edge))\n", + "hist, bin_edges = np.histogram(\n", + " missingMomentumDipion.m2, 100, range=(low_edge, up_edge)\n", + ")\n", "integral_hist = np.sum(hist)\n", "hist = hist / integral_hist\n", "\n", @@ -1043,7 +1052,10 @@ "x_hist_2 = np.linspace(np.min(x_hist), np.max(x_hist), 100)\n", "# this plots the curve only\n", "ax[0].plot(\n", - " x_hist_2, gausAndBCK(x_hist_2, *param_optimised), color=\"red\", label=\"Gaussian fit\"\n", + " x_hist_2,\n", + " gausAndBCK(x_hist_2, *param_optimised),\n", + " color=\"red\",\n", + " label=\"Gaussian fit\",\n", ")\n", "ax[0].plot(x_hist_2, gaus(x_hist_2, *param_optimised_gauss), color=\"cyan\")\n", "ax[0].plot(x_hist_2, BCK(x_hist_2, *param_optimised_bck), color=\"magenta\")\n", @@ -1081,6 +1093,9 @@ } ], "metadata": { + "colab": { + "toc_visible": true + }, "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", diff --git a/docs/lecture06-nbarp.ipynb b/docs/lecture06-nbarp.ipynb index ad91663..dfacc6e 100644 --- a/docs/lecture06-nbarp.ipynb +++ b/docs/lecture06-nbarp.ipynb @@ -455,13 +455,21 @@ "outputs": [], "source": [ "fig, ax = plt.subplots(1, 2, tight_layout=True, figsize=(7, 4))\n", - "ax[0].hist2d(invariant_massSquared13mc, invariant_massSquared12mc, bins=100, cmap=\"jet\")\n", - "ax[0].hist2d(invariant_massSquared23mc, invariant_massSquared12mc, bins=100, cmap=\"jet\")\n", + "ax[0].hist2d(\n", + " invariant_massSquared13mc, invariant_massSquared12mc, bins=100, cmap=\"jet\"\n", + ")\n", + "ax[0].hist2d(\n", + " invariant_massSquared23mc, invariant_massSquared12mc, bins=100, cmap=\"jet\"\n", + ")\n", "# ax[0].colorbar()\n", "ax[0].set_xlabel(R\"i.m.$^2(\\pi^+_{(1,2)}\\pi^-_{3}$) [GeV$^2$]\")\n", "ax[0].set_ylabel(R\"i.m.$^2(\\pi^+\\pi^+$) [GeV$^2$]\")\n", - "ax[1].hist2d(invariant_massSquared13mc, invariant_massSquared23mc, bins=100, cmap=\"jet\")\n", - "ax[1].hist2d(invariant_massSquared23mc, invariant_massSquared13mc, bins=100, cmap=\"jet\")\n", + "ax[1].hist2d(\n", + " invariant_massSquared13mc, invariant_massSquared23mc, bins=100, cmap=\"jet\"\n", + ")\n", + "ax[1].hist2d(\n", + " invariant_massSquared23mc, invariant_massSquared13mc, bins=100, cmap=\"jet\"\n", + ")\n", "ax[1].set_xlabel(R\"i.m.$^2(\\pi^+_1\\pi^-$) [GeV$^2$]\")\n", "ax[1].set_ylabel(R\"i.m.$^2(\\pi^+_2\\pi^-$) [GeV$^2$]\")\n", "plt.show()" @@ -627,6 +635,9 @@ } ], "metadata": { + "colab": { + "toc_visible": true + }, "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", diff --git a/docs/lecture09.ipynb b/docs/lecture09.ipynb index 7acaa78..be9806e 100644 --- a/docs/lecture09.ipynb +++ b/docs/lecture09.ipynb @@ -2456,7 +2456,8 @@ "def like(param):\n", " a, b = param\n", " return sum(\n", - " 2 * (func(x, a, b) - y * np.log(func(x, a, b))) for x, y in zip(data_x, data_y)\n", + " 2 * (func(x, a, b) - y * np.log(func(x, a, b)))\n", + " for x, y in zip(data_x, data_y)\n", " )" ] }, @@ -3217,6 +3218,9 @@ } ], "metadata": { + "colab": { + "toc_visible": true + }, "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", diff --git a/docs/lecture12a-gammap-solution.ipynb b/docs/lecture12a-gammap-solution.ipynb index 29842fd..e0f70ed 100755 --- a/docs/lecture12a-gammap-solution.ipynb +++ b/docs/lecture12a-gammap-solution.ipynb @@ -314,7 +314,9 @@ "source": [ "# @title Solution\n", "plt.hist(invariant_mass_13, bins=200, color=\"tomato\", range=(1.0, 2.0))\n", - "plt.hist(invariant_mass_23, bins=200, color=\"darkmagenta\", alpha=0.4, range=(1.0, 2.0))\n", + "plt.hist(\n", + " invariant_mass_23, bins=200, color=\"darkmagenta\", alpha=0.4, range=(1.0, 2.0)\n", + ")\n", "plt.xlabel(\"Invariant mass [GeV]\")\n", "plt.ylabel(\"Entries/(5 MeV)\")\n", "plt.show()" @@ -515,7 +517,9 @@ "ax[0].set_ylabel(\"Entries/(12 MeV)\")\n", "ax[0].set_title(\"($\\\\pi^+\\\\pi^-$) i.m. \\n\")\n", "# plot the histogram pi+p\n", - "ax[1].hist(np.sqrt(inv_mass_squared_13_mc), color=\"tomato\", bins=100, range=(1.0, 2.0))\n", + "ax[1].hist(\n", + " np.sqrt(inv_mass_squared_13_mc), color=\"tomato\", bins=100, range=(1.0, 2.0)\n", + ")\n", "ax[1].set_xlabel(R\"($\\pi^+p$) Invariant mass [GeV]\")\n", "ax[1].set_ylabel(\"Entries/(10 MeV)\")\n", "ax[1].set_title(\"($\\\\pi^+p$) i.m. \\n\")\n", @@ -788,7 +792,9 @@ "fig = plt.figure()\n", "x_hist_2 = np.linspace(np.min(x_hist), np.max(x_hist), 100)\n", "# this plots the curve only\n", - "plt.plot(x_hist_2, gaus(x_hist_2, *param_optimised), color=\"red\", label=\"Gaussian fit\")\n", + "plt.plot(\n", + " x_hist_2, gaus(x_hist_2, *param_optimised), color=\"red\", label=\"Gaussian fit\"\n", + ")\n", "plt.legend()\n", "\n", "# plot the experimental point of the portion of spectrum to be fitted\n", @@ -900,7 +906,9 @@ "fig = plt.figure()\n", "x_hist_2 = np.linspace(np.min(x_hist), np.max(x_hist), 100)\n", "# this plots the curve only\n", - "plt.plot(x_hist_2, gaus(x_hist_2, *param_optimised), color=\"red\", label=\"Gaussian fit\")\n", + "plt.plot(\n", + " x_hist_2, gaus(x_hist_2, *param_optimised), color=\"red\", label=\"Gaussian fit\"\n", + ")\n", "plt.legend()\n", "\n", "# plot the experimental point of the portion of spectrum to be fitted\n", @@ -1035,7 +1043,10 @@ "x_hist_2 = np.linspace(np.min(x_hist), np.max(x_hist), 100)\n", "# this plots the curve only\n", "ax[0].plot(\n", - " x_hist_2, gausAndBCK(x_hist_2, *param_optimised), color=\"red\", label=\"Gaussian fit\"\n", + " x_hist_2,\n", + " gausAndBCK(x_hist_2, *param_optimised),\n", + " color=\"red\",\n", + " label=\"Gaussian fit\",\n", ")\n", "ax[0].plot(x_hist_2, gaus(x_hist_2, *param_optimised_gauss), color=\"cyan\")\n", "ax[0].plot(x_hist_2, BCK(x_hist_2, *param_optimised_bck), color=\"magenta\")\n", @@ -1100,7 +1111,9 @@ "# normalize the histogram to 1\n", "low_edge = 0.8\n", "up_edge = 1.0\n", - "hist, bin_edges = np.histogram(missingMomentumDipion.m2, 100, range=(low_edge, up_edge))\n", + "hist, bin_edges = np.histogram(\n", + " missingMomentumDipion.m2, 100, range=(low_edge, up_edge)\n", + ")\n", "integral_hist = np.sum(hist)\n", "hist = hist / integral_hist\n", "\n", @@ -1164,7 +1177,10 @@ "x_hist_2 = np.linspace(np.min(x_hist), np.max(x_hist), 100)\n", "# this plots the curve only\n", "ax[0].plot(\n", - " x_hist_2, gausAndBCK(x_hist_2, *param_optimised), color=\"red\", label=\"Gaussian fit\"\n", + " x_hist_2,\n", + " gausAndBCK(x_hist_2, *param_optimised),\n", + " color=\"red\",\n", + " label=\"Gaussian fit\",\n", ")\n", "ax[0].plot(x_hist_2, gaus(x_hist_2, *param_optimised_gauss), color=\"cyan\")\n", "ax[0].plot(x_hist_2, BCK(x_hist_2, *param_optimised_bck), color=\"magenta\")\n", @@ -1202,6 +1218,9 @@ } ], "metadata": { + "colab": { + "toc_visible": true + }, "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", diff --git a/docs/lecture12b-kinematics.ipynb b/docs/lecture12b-kinematics.ipynb index 9558d78..8d03eb2 100644 --- a/docs/lecture12b-kinematics.ipynb +++ b/docs/lecture12b-kinematics.ipynb @@ -192,13 +192,21 @@ "outputs": [], "source": [ "fig, ax = plt.subplots(1, 2, tight_layout=True, figsize=(9, 4))\n", - "h0 = ax[0].hist2d(invariantMassSquared13, invariantMassSquared12, bins=100, cmap=\"jet\")\n", - "h0 = ax[0].hist2d(invariantMassSquared23, invariantMassSquared12, bins=100, cmap=\"jet\")\n", + "h0 = ax[0].hist2d(\n", + " invariantMassSquared13, invariantMassSquared12, bins=100, cmap=\"jet\"\n", + ")\n", + "h0 = ax[0].hist2d(\n", + " invariantMassSquared23, invariantMassSquared12, bins=100, cmap=\"jet\"\n", + ")\n", "fig.colorbar(h0[3], ax=ax[0])\n", "ax[0].set_xlabel(R\"i.m.$^2(\\pi^+_{(1,2)}\\pi^-_{3}$) [GeV$^2$]\")\n", "ax[0].set_ylabel(R\"i.m.$^2(\\pi^+\\pi^+$) [GeV$^2$]\")\n", - "h1 = ax[1].hist2d(invariantMassSquared13, invariantMassSquared23, bins=100, cmap=\"jet\")\n", - "h1 = ax[1].hist2d(invariantMassSquared23, invariantMassSquared13, bins=100, cmap=\"jet\")\n", + "h1 = ax[1].hist2d(\n", + " invariantMassSquared13, invariantMassSquared23, bins=100, cmap=\"jet\"\n", + ")\n", + "h1 = ax[1].hist2d(\n", + " invariantMassSquared23, invariantMassSquared13, bins=100, cmap=\"jet\"\n", + ")\n", "fig.colorbar(h1[3], ax=ax[1])\n", "ax[1].set_xlabel(R\"i.m.$^2(\\pi^+_1\\pi^-$) [GeV$^2$]\")\n", "ax[1].set_ylabel(R\"i.m.$^2(\\pi^+_2\\pi^-$) [GeV$^2$]\")\n", @@ -371,11 +379,15 @@ "source": [ "fig, ax = plt.subplots(2, 2, tight_layout=True, figsize=(9, 4))\n", "ax[0, 0].hist(u_lab_1, bins=100, color=\"HotPink\")\n", - "ax[0, 0].set_xlabel(R\"u = $(p_{nbar} - p_{\\pi^+_2})^2$ lab RF [$(\\mathrm{GeV}/c^2)^2$]\")\n", + "ax[0, 0].set_xlabel(\n", + " R\"u = $(p_{nbar} - p_{\\pi^+_2})^2$ lab RF [$(\\mathrm{GeV}/c^2)^2$]\"\n", + ")\n", "ax[0, 1].hist(u_lab_2, bins=100, color=\"DeepPink\")\n", "ax[0, 1].set_xlabel(R\"u = $(p_p - p_D)^2$ lab RF [$(\\mathrm{GeV}/c^2)^2$]\")\n", "ax[1, 0].hist(u_cm_1, bins=100, color=\"Fuchsia\")\n", - "ax[1, 0].set_xlabel(R\"u = $(p_{nbar} - p_{\\pi^+_2})^2$ CM RF [$(\\mathrm{GeV}/c^2)^2$]\")\n", + "ax[1, 0].set_xlabel(\n", + " R\"u = $(p_{nbar} - p_{\\pi^+_2})^2$ CM RF [$(\\mathrm{GeV}/c^2)^2$]\"\n", + ")\n", "ax[1, 1].hist(u_cm_2, bins=100, color=\"DarkMagenta\")\n", "ax[1, 1].set_xlabel(R\"u = $(p_p - p_D)^2$ CM RF [$(\\mathrm{GeV}/c^2)^2$]\")\n", "plt.show()" @@ -542,6 +554,9 @@ } ], "metadata": { + "colab": { + "toc_visible": true + }, "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", diff --git a/docs/lecture12c-angles.ipynb b/docs/lecture12c-angles.ipynb index de29cc4..f718734 100644 --- a/docs/lecture12c-angles.ipynb +++ b/docs/lecture12c-angles.ipynb @@ -353,6 +353,9 @@ } ], "metadata": { + "colab": { + "toc_visible": true + }, "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", diff --git a/docs/lecture12d-phasespace.ipynb b/docs/lecture12d-phasespace.ipynb index 37c03fe..24d0ed4 100644 --- a/docs/lecture12d-phasespace.ipynb +++ b/docs/lecture12d-phasespace.ipynb @@ -541,6 +541,9 @@ } ], "metadata": { + "colab": { + "toc_visible": true + }, "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", diff --git a/docs/lecture12e-longitudinal.ipynb b/docs/lecture12e-longitudinal.ipynb index 90cf4c2..99a2d36 100644 --- a/docs/lecture12e-longitudinal.ipynb +++ b/docs/lecture12e-longitudinal.ipynb @@ -230,6 +230,9 @@ } ], "metadata": { + "colab": { + "toc_visible": true + }, "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", diff --git a/docs/lecture17.ipynb b/docs/lecture17.ipynb index fb0d9bd..80daf3c 100755 --- a/docs/lecture17.ipynb +++ b/docs/lecture17.ipynb @@ -676,7 +676,10 @@ "outputs": [], "source": [ "T_exprs = [\n", - " T(s, m, MĪ, GV, fĪ€, g0, sign).doit().xreplace(substitutions).xreplace(substitutions)\n", + " T(s, m, MĪ, GV, fĪ€, g0, sign)\n", + " .doit()\n", + " .xreplace(substitutions)\n", + " .xreplace(substitutions)\n", " for sign in [-1, +1]\n", "]\n", "T_funcs = [sp.lambdify(s, expr) for expr in T_exprs]" @@ -713,7 +716,9 @@ " surfacecolor=t.imag,\n", ")\n", "Sn = go.Surface(x=X, y=Yn, z=Tn.real, **sty(Tn), name=\"Unphysical\")\n", - "Sp = go.Surface(x=X, y=Yp, z=Tp.real, **sty(Tp), name=\"Physical\", colorbar_title=\"Re T\")\n", + "Sp = go.Surface(\n", + " x=X, y=Yp, z=Tp.real, **sty(Tp), name=\"Physical\", colorbar_title=\"Re T\"\n", + ")\n", "y = Yp[0]\n", "z = x + y * 1j\n", "line = go.Scatter3d(\n", @@ -755,7 +760,9 @@ " surfacecolor=t.real,\n", ")\n", "Sn = go.Surface(x=X, y=Yn, z=Tn.imag, **sty(Tn), name=\"Unphysical\")\n", - "Sp = go.Surface(x=X, y=Yp, z=Tp.imag, **sty(Tp), name=\"Physical\", colorbar_title=\"Im T\")\n", + "Sp = go.Surface(\n", + " x=X, y=Yp, z=Tp.imag, **sty(Tp), name=\"Physical\", colorbar_title=\"Im T\"\n", + ")\n", "y = Yp[0]\n", "z = x + y * 1j\n", "line = go.Scatter3d(\n", @@ -778,6 +785,9 @@ } ], "metadata": { + "colab": { + "toc_visible": true + }, "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", diff --git a/docs/lecture18.ipynb b/docs/lecture18.ipynb index 523f02f..0ffba78 100755 --- a/docs/lecture18.ipynb +++ b/docs/lecture18.ipynb @@ -572,6 +572,9 @@ } ], "metadata": { + "colab": { + "toc_visible": true + }, "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", diff --git a/docs/lecture24.ipynb b/docs/lecture24.ipynb index 6e8ea63..ce67cb4 100644 --- a/docs/lecture24.ipynb +++ b/docs/lecture24.ipynb @@ -294,7 +294,9 @@ "# call utility function histSqrtErrorBars to raw histograms with error bars\n", "mass_hist = s2020.histSqrtErrorBars(mass, massbins, \"all\")\n", "sig_mass_hist = s2020.histSqrtErrorBars(mass[np.abs(state) == 1], massbins, \"signal\")\n", - "bg_mass_hist = s2020.histSqrtErrorBars(mass[np.abs(state) == 2], massbins, \"background\")\n", + "bg_mass_hist = s2020.histSqrtErrorBars(\n", + " mass[np.abs(state) == 2], massbins, \"background\"\n", + ")\n", "plt.legend(loc=\"upper right\")\n", "plt.show()" ] @@ -512,7 +514,10 @@ "para_sig_phi_hist = s2020.histSqrtErrorBars(sig_pos_phi, phibins, \"signal\")\n", "# plot a photon asymmetry function with guess parameters N=150*2pi, Sigma = -0.7\n", "plt.plot(\n", - " phibins, PhotonAsymmetryN(phibins, -0.7, 150 * 2 * np.pi), \"r-\", label=\"first guess\"\n", + " phibins,\n", + " PhotonAsymmetryN(phibins, -0.7, 150 * 2 * np.pi),\n", + " \"r-\",\n", + " label=\"first guess\",\n", ")\n", "plt.show()" ] @@ -1041,7 +1046,13 @@ "source": [ "Ndata = bg_pos_mass.size\n", "mi = Minuit(\n", - " ExtendedUnbinnedNLL(bg_pos_mass, BgMassNExt), c0=1, c1=0, c2=0, c3=0, c4=0, Nb=Ndata\n", + " ExtendedUnbinnedNLL(bg_pos_mass, BgMassNExt),\n", + " c0=1,\n", + " c1=0,\n", + " c2=0,\n", + " c3=0,\n", + " c4=0,\n", + " Nb=Ndata,\n", ")\n", "\n", "mi.limits[\"Nb\"] = (0, Ndata * 1.1)\n", @@ -1102,7 +1113,8 @@ "para_bg_mass_hist = s2020.histSqrtErrorBars(mass[state == 2], massbins, \"background\")\n", "plt.plot(\n", " massbins,\n", - " BgMassNExt(massbins, bg_c1, bg_c2, bg_c3, bg_c4, bg_c5, Nminuit)[1] / massbins.size,\n", + " BgMassNExt(massbins, bg_c1, bg_c2, bg_c3, bg_c4, bg_c5, Nminuit)[1]\n", + " / massbins.size,\n", " \"r-\",\n", " label=\"best fit\",\n", ")\n", @@ -1311,7 +1323,16 @@ "plt.plot(\n", " massbins,\n", " CombinedMassNExt(\n", - " massbins, sg_mean, sg_width, bg_c1, bg_c2, bg_c3, bg_c4, bg_c5, Ysignal, Yback\n", + " massbins,\n", + " sg_mean,\n", + " sg_width,\n", + " bg_c1,\n", + " bg_c2,\n", + " bg_c3,\n", + " bg_c4,\n", + " bg_c5,\n", + " Ysignal,\n", + " Yback,\n", " )[1]\n", " / massbins.size,\n", " \"r-\",\n", @@ -1668,7 +1689,10 @@ "\n", "bestSigmaWgtd = mi.values[0]\n", "print(\n", - " \"best value for background subtracted Sigma = \", bestSigmaWgtd, \"+-\", mi.errors[0]\n", + " \"best value for background subtracted Sigma = \",\n", + " bestSigmaWgtd,\n", + " \"+-\",\n", + " mi.errors[0],\n", ")" ] }, @@ -2590,6 +2614,9 @@ } ], "metadata": { + "colab": { + "toc_visible": true + }, "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", diff --git a/docs/lecture24_utilities.ipynb b/docs/lecture24_utilities.ipynb index 7ddda3c..c5df6de 100644 --- a/docs/lecture24_utilities.ipynb +++ b/docs/lecture24_utilities.ipynb @@ -70,7 +70,9 @@ " sumweight_sqrd, edges = np.histogram(data, weights=wgts * wgts, bins=xbins)\n", " errs = np.sqrt(sumweight_sqrd)\n", " bincenters = (xbins[1:] + xbins[:-1]) / 2 + offset\n", - " histo = plt.errorbar(bincenters, sumweights, errs, linewidth=1, fmt=\".\", label=lab)\n", + " histo = plt.errorbar(\n", + " bincenters, sumweights, errs, linewidth=1, fmt=\".\", label=lab\n", + " )\n", " return histo" ] }, @@ -81,6 +83,9 @@ } ], "metadata": { + "colab": { + "toc_visible": true + }, "kernelspec": { "display_name": "Python 3", "name": "python3" diff --git a/environment.yml b/environment.yml index ae6db5a..81165f1 100644 --- a/environment.yml +++ b/environment.yml @@ -1,4 +1,4 @@ -name: strong2020 +name: strong2020-salamanca dependencies: - python==3.10.* - pip