Skip to content

Commit

Permalink
MAINT: autoupdate pre-commit hooks (#19)
Browse files Browse the repository at this point in the history
* DOC: make Colab TOC visible by default
* DX: lint PRs with shared commitlint config
* DX: merge `setup.cfg` into `pyproject.toml`
* DX: switch to `black-jupyter` hook
* DX: remove `.prettierrc`
* DX: remove GitHub Issue templates
* DX: synchronize ComPWA dev environment

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
redeboer and pre-commit-ci[bot] authored Oct 9, 2023
1 parent 6ef58fe commit ff9492c
Show file tree
Hide file tree
Showing 20 changed files with 260 additions and 44 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/clean-caches.yml
Original file line number Diff line number Diff line change
@@ -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 }}
33 changes: 33 additions & 0 deletions .github/workflows/pr-linting.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected] # cspell:ignore kode
41 changes: 33 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -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
Expand Down
7 changes: 7 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"
]
}
9 changes: 8 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -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
}
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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)

Expand All @@ -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):
Expand Down
3 changes: 3 additions & 0 deletions docs/lecture02.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,9 @@
}
],
"metadata": {
"colab": {
"toc_visible": true
},
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
Expand Down
25 changes: 20 additions & 5 deletions docs/lecture06-gammap.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -1081,6 +1093,9 @@
}
],
"metadata": {
"colab": {
"toc_visible": true
},
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
Expand Down
19 changes: 15 additions & 4 deletions docs/lecture06-nbarp.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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()"
Expand Down Expand Up @@ -627,6 +635,9 @@
}
],
"metadata": {
"colab": {
"toc_visible": true
},
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
Expand Down
6 changes: 5 additions & 1 deletion docs/lecture09.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
" )"
]
},
Expand Down Expand Up @@ -3217,6 +3218,9 @@
}
],
"metadata": {
"colab": {
"toc_visible": true
},
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
Expand Down
Loading

0 comments on commit ff9492c

Please sign in to comment.