diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..cce3aa5 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +layout anaconda diff --git a/.github/workflows/constraints.yml b/.github/workflows/constraints.yml index 3cac60d..b87dcca 100644 --- a/.github/workflows/constraints.yml +++ b/.github/workflows/constraints.yml @@ -24,9 +24,9 @@ jobs: - uses: actions/setup-python@v5 with: python-version: "3.8" - - run: pip install pip-tools - - run: pip-compile --no-annotate --strip-extras --upgrade binder/requirements.in - - run: pip-compile --no-annotate --strip-extras --upgrade requirements.in + - run: pip install uv + - run: uv pip compile binder/requirements.in -o binder/requirements.txt --no-annotate --strip-extras --upgrade + - run: uv pip compile requirements.in -o requirements.txt --no-annotate --strip-extras --upgrade - uses: actions/upload-artifact@v4 with: name: pip-constraints diff --git a/.gitignore b/.gitignore index 9727aa9..22223ed 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ *.csv +*.egg-info/ .ipynb_checkpoints/ .tox/ condaenv.*.requirements.txt diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index acfefbf..2d35776 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -20,8 +20,10 @@ repos: - | cell.attachments cell.metadata.code_folding + cell.metadata.editable cell.metadata.id cell.metadata.pycharm + cell.metadata.slideshow cell.metadata.user_expressions metadata.celltoolbar metadata.colab.name @@ -37,7 +39,7 @@ repos: metadata.vscode - repo: https://github.com/ComPWA/policy - rev: 0.3.4 + rev: 0.3.18 hooks: - id: check-dev-files args: @@ -46,24 +48,23 @@ repos: - --no-gitpod - --no-prettierrc - --no-pypi - - --no-python - - --no-ruff - --no-version-branches - --repo-name=ComPWA-demo - --repo-title="ComPWA demos" - id: colab-toc-visible + - id: remove-empty-tags - - repo: https://github.com/nbQA-dev/nbQA - rev: 1.8.5 + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.5.6 hooks: - - id: nbqa-flake8 - - id: nbqa-isort - - id: nbqa-pyupgrade - args: - - --py36-plus + - 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 + rev: v4.6.0 hooks: - id: check-case-conflict - id: check-json @@ -79,11 +80,6 @@ repos: - id: mixed-line-ending - id: trailing-whitespace - - 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: @@ -101,13 +97,8 @@ repos: args: - --in-place - - repo: https://github.com/psf/black - rev: 24.3.0 - hooks: - - id: black-jupyter - - repo: https://github.com/streetsidesoftware/cspell-cli - rev: v8.6.1 + rev: v8.13.1 hooks: - id: cspell diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..fa65608 --- /dev/null +++ b/.prettierignore @@ -0,0 +1 @@ +*.ipynb diff --git a/.vscode/extensions.json b/.vscode/extensions.json index d128869..7f72746 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,12 +1,10 @@ { "recommendations": [ + "charliermarsh.ruff", "eamodio.gitlens", "editorconfig.editorconfig", "esbenp.prettier-vscode", "github.vscode-github-actions", - "ms-python.black-formatter", - "ms-python.flake8", - "ms-python.isort", "ms-python.python", "ms-vsliveshare.vsliveshare", "redhat.vscode-yaml", @@ -20,6 +18,10 @@ "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", "ms-python.pylint", "travisillig.vscode-json-stable-stringify", "tyriar.sort-lines" diff --git a/.vscode/settings.json b/.vscode/settings.json index 596cf2d..cf31567 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -3,9 +3,7 @@ "editor.formatOnSave": false }, "[git-commit]": { - "editor.rulers": [ - 72 - ], + "editor.rulers": [72], "rewrap.wrappingColumn": 72 }, "[ipynb]": { @@ -24,7 +22,8 @@ "[python]": { "editor.codeActionsOnSave": { "source.organizeImports": "explicit" - } + }, + "editor.defaultFormatter": "charliermarsh.ruff" }, "[yaml]": { "editor.defaultFormatter": "esbenp.prettier-vscode" @@ -33,15 +32,21 @@ "diffEditor.experimental.showMoves": true, "editor.formatOnSave": true, "git.rebaseWhenSync": true, - "github-actions.workflows.pinned.workflows": [ - ".github/workflows/ci.yml" - ], + "github-actions.workflows.pinned.workflows": [".github/workflows/ci.yml"], "gitlens.telemetry.enabled": false, "multiDiffEditor.experimental.enabled": true, + "notebook.codeActionsOnSave": { + "notebook.source.organizeImports": "explicit" + }, + "notebook.formatOnSave.enabled": true, "python.analysis.autoImportCompletions": false, "python.languageServer": "Pylance", + "python.terminal.activateEnvironment": false, "python.testing.unittestEnabled": false, "redhat.telemetry.enabled": false, "rewrap.wrappingColumn": 88, + "ruff.enable": true, + "ruff.importStrategy": "fromEnvironment", + "ruff.organizeImports": true, "telemetry.telemetryLevel": "off" } diff --git a/2021.11.29/ampform.ipynb b/2021.11.29/ampform.ipynb index 5ebc9b5..2d9ce84 100644 --- a/2021.11.29/ampform.ipynb +++ b/2021.11.29/ampform.ipynb @@ -22,9 +22,7 @@ }, { "cell_type": "markdown", - "metadata": { - "tags": [] - }, + "metadata": {}, "source": [ "## Install dependencies" ] @@ -44,8 +42,7 @@ "metadata": { "jupyter": { "source_hidden": true - }, - "tags": [] + } }, "outputs": [], "source": [ @@ -131,9 +128,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "tags": [] - }, + "metadata": {}, "outputs": [], "source": [ "dot = qrules.io.asdot(reaction, collapse_graphs=True, render_final_state_id=True)\n", @@ -177,8 +172,7 @@ "metadata": { "jupyter": { "source_hidden": true - }, - "tags": [] + } }, "outputs": [], "source": [ @@ -215,8 +209,7 @@ "metadata": { "jupyter": { "source_hidden": true - }, - "tags": [] + } }, "outputs": [], "source": [ @@ -262,8 +255,7 @@ "metadata": { "jupyter": { "source_hidden": true - }, - "tags": [] + } }, "outputs": [], "source": [ diff --git a/2021.11.29/qrules.ipynb b/2021.11.29/qrules.ipynb index 315fc39..7f06978 100644 --- a/2021.11.29/qrules.ipynb +++ b/2021.11.29/qrules.ipynb @@ -32,9 +32,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "tags": [] - }, + "metadata": {}, "outputs": [], "source": [ "%load_ext autoreload\n", @@ -73,9 +71,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "tags": [] - }, + "metadata": {}, "outputs": [], "source": [ "dot = qrules.io.asdot(reaction, collapse_graphs=True)\n", @@ -95,8 +91,7 @@ "metadata": { "jupyter": { "source_hidden": true - }, - "tags": [] + } }, "outputs": [], "source": [ diff --git a/2021.11.29/tensorwaves-0.3.4.ipynb b/2021.11.29/tensorwaves-0.3.4.ipynb index 9668868..186590c 100644 --- a/2021.11.29/tensorwaves-0.3.4.ipynb +++ b/2021.11.29/tensorwaves-0.3.4.ipynb @@ -22,9 +22,7 @@ }, { "cell_type": "markdown", - "metadata": { - "tags": [] - }, + "metadata": {}, "source": [ "## Install dependencies" ] @@ -32,9 +30,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "tags": [] - }, + "metadata": {}, "outputs": [], "source": [ "%pip install -q ampform[viz]==0.11.* tensorwaves[jax]==0.3.4 tensorflow==2.7.*" @@ -46,8 +42,7 @@ "metadata": { "jupyter": { "source_hidden": true - }, - "tags": [] + } }, "outputs": [], "source": [ @@ -60,7 +55,7 @@ "\n", "import ampform\n", "import graphviz\n", - "import matplotlib\n", + "import matplotlib as mpl\n", "import matplotlib.pyplot as plt\n", "import numpy as np\n", "import qrules\n", @@ -82,7 +77,7 @@ "tf.get_logger().setLevel(\"WARNING\")\n", "warnings.filterwarnings(\"ignore\")\n", "\n", - "matplotlib.rcParams.update({\"font.size\": 14})\n", + "mpl.rcParams.update({\"font.size\": 14})\n", "np_config.enable_numpy_behavior()\n", "\n", "has_tf_gpu = bool(tf.config.list_physical_devices(\"GPU\"))\n", @@ -104,8 +99,7 @@ "metadata": { "jupyter": { "source_hidden": true - }, - "tags": [] + } }, "outputs": [], "source": [ @@ -202,8 +196,7 @@ "metadata": { "jupyter": { "source_hidden": true - }, - "tags": [] + } }, "outputs": [], "source": [ @@ -248,9 +241,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "tags": [] - }, + "metadata": {}, "outputs": [], "source": [ "template = SympyModel(\n", @@ -288,8 +279,7 @@ "metadata": { "jupyter": { "source_hidden": true - }, - "tags": [] + } }, "outputs": [], "source": [ @@ -355,8 +345,7 @@ "metadata": { "jupyter": { "source_hidden": true - }, - "tags": [] + } }, "outputs": [], "source": [ @@ -377,8 +366,7 @@ "metadata": { "jupyter": { "source_hidden": true - }, - "tags": [] + } }, "outputs": [], "source": [ diff --git a/2021.11.29/tensorwaves.ipynb b/2021.11.29/tensorwaves.ipynb index 77f3404..9a206d1 100644 --- a/2021.11.29/tensorwaves.ipynb +++ b/2021.11.29/tensorwaves.ipynb @@ -22,9 +22,7 @@ }, { "cell_type": "markdown", - "metadata": { - "tags": [] - }, + "metadata": {}, "source": [ "## Install dependencies" ] @@ -32,9 +30,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "tags": [] - }, + "metadata": {}, "outputs": [], "source": [ "%pip install -q ampform[viz]==0.11.* tensorwaves[jax]==0.3.7" @@ -46,8 +42,7 @@ "metadata": { "jupyter": { "source_hidden": true - }, - "tags": [] + } }, "outputs": [], "source": [ @@ -60,7 +55,7 @@ "\n", "import ampform\n", "import graphviz\n", - "import matplotlib\n", + "import matplotlib as mpl\n", "import matplotlib.pyplot as plt\n", "import numpy as np\n", "import qrules\n", @@ -82,7 +77,7 @@ "tf.get_logger().setLevel(\"WARNING\")\n", "warnings.filterwarnings(\"ignore\")\n", "\n", - "matplotlib.rcParams.update({\"font.size\": 14})\n", + "mpl.rcParams.update({\"font.size\": 14})\n", "np_config.enable_numpy_behavior()\n", "\n", "has_tf_gpu = bool(tf.config.list_physical_devices(\"GPU\"))\n", @@ -104,8 +99,7 @@ "metadata": { "jupyter": { "source_hidden": true - }, - "tags": [] + } }, "outputs": [], "source": [ @@ -203,8 +197,7 @@ "metadata": { "jupyter": { "source_hidden": true - }, - "tags": [] + } }, "outputs": [], "source": [ @@ -249,9 +242,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "tags": [] - }, + "metadata": {}, "outputs": [], "source": [ "template = SympyModel(\n", @@ -288,8 +279,7 @@ "metadata": { "jupyter": { "source_hidden": true - }, - "tags": [] + } }, "outputs": [], "source": [ @@ -355,8 +345,7 @@ "metadata": { "jupyter": { "source_hidden": true - }, - "tags": [] + } }, "outputs": [], "source": [ @@ -377,8 +366,7 @@ "metadata": { "jupyter": { "source_hidden": true - }, - "tags": [] + } }, "outputs": [], "source": [ diff --git a/2021.12.13/ampform.ipynb b/2021.12.13/ampform.ipynb index 01d831d..2f8a090 100644 --- a/2021.12.13/ampform.ipynb +++ b/2021.12.13/ampform.ipynb @@ -22,9 +22,7 @@ }, { "cell_type": "markdown", - "metadata": { - "tags": [] - }, + "metadata": {}, "source": [ "## Install dependencies" ] @@ -44,8 +42,7 @@ "metadata": { "jupyter": { "source_hidden": true - }, - "tags": [] + } }, "outputs": [], "source": [ @@ -140,9 +137,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "tags": [] - }, + "metadata": {}, "outputs": [], "source": [ "dot = qrules.io.asdot(reaction, collapse_graphs=True, render_final_state_id=True)\n", @@ -186,8 +181,7 @@ "metadata": { "jupyter": { "source_hidden": true - }, - "tags": [] + } }, "outputs": [], "source": [ @@ -224,8 +218,7 @@ "metadata": { "jupyter": { "source_hidden": true - }, - "tags": [] + } }, "outputs": [], "source": [ @@ -274,8 +267,7 @@ "metadata": { "jupyter": { "source_hidden": true - }, - "tags": [] + } }, "outputs": [], "source": [ @@ -295,8 +287,7 @@ "metadata": { "jupyter": { "source_hidden": true - }, - "tags": [] + } }, "outputs": [], "source": [ @@ -416,8 +407,7 @@ "metadata": { "jupyter": { "source_hidden": true - }, - "tags": [] + } }, "outputs": [], "source": [ @@ -441,8 +431,7 @@ "metadata": { "jupyter": { "source_hidden": true - }, - "tags": [] + } }, "outputs": [], "source": [ @@ -462,14 +451,13 @@ "metadata": { "jupyter": { "source_hidden": true - }, - "tags": [] + } }, "outputs": [], "source": [ "expr_subs = expr.subs(mass_substitutions)\n", "expr_subs = round_nested(expr_subs, n_decimals=2)\n", - "node = [s for s in sp.preorder_traversal(expr_subs) if isinstance(s, sp.Float)][0]\n", + "node = next(s for s in sp.preorder_traversal(expr_subs) if isinstance(s, sp.Float))\n", "dot = sp.dotprint(expr_subs.subs(node, Symbol(f\"{node}\")), **graph_style)\n", "display(expr_subs.subs(node, sp.Symbol(Rf\"\\color{{RoyalBlue}}{node}\")))\n", "graphviz.Source(dot)" @@ -477,9 +465,7 @@ }, { "cell_type": "markdown", - "metadata": { - "tags": [] - }, + "metadata": {}, "source": [ "## Symbolic kinematic variables" ] @@ -507,9 +493,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "tags": [] - }, + "metadata": {}, "outputs": [], "source": [ "model.kinematic_variables[theta_1_12].doit()" diff --git a/2021.12.13/qrules.ipynb b/2021.12.13/qrules.ipynb index 38ce018..05e50c5 100644 --- a/2021.12.13/qrules.ipynb +++ b/2021.12.13/qrules.ipynb @@ -32,9 +32,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "tags": [] - }, + "metadata": {}, "outputs": [], "source": [ "%load_ext autoreload\n", @@ -46,9 +44,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "tags": [] - }, + "metadata": {}, "outputs": [], "source": [ "PDG = qrules.load_pdg()\n", @@ -58,9 +54,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "tags": [] - }, + "metadata": {}, "outputs": [], "source": [ "selection = PDG.filter(\n", @@ -76,9 +70,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "tags": [] - }, + "metadata": {}, "outputs": [], "source": [ "qrules.check_reaction_violations(\n", @@ -117,9 +109,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "tags": [] - }, + "metadata": {}, "outputs": [], "source": [ "dot = qrules.io.asdot(reaction, collapse_graphs=True)\n", @@ -139,8 +129,7 @@ "metadata": { "jupyter": { "source_hidden": true - }, - "tags": [] + } }, "outputs": [], "source": [ diff --git a/2021.12.13/tensorwaves-caching.ipynb b/2021.12.13/tensorwaves-caching.ipynb index 3aa034f..37e565b 100644 --- a/2021.12.13/tensorwaves-caching.ipynb +++ b/2021.12.13/tensorwaves-caching.ipynb @@ -24,9 +24,7 @@ }, { "cell_type": "markdown", - "metadata": { - "tags": [] - }, + "metadata": {}, "source": [ "## Install dependencies" ] @@ -34,9 +32,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "tags": [] - }, + "metadata": {}, "outputs": [], "source": [ "%pip install -q ampform[viz]==0.12.* tensorwaves[jax,pwa]==0.4.*" @@ -48,8 +44,7 @@ "metadata": { "jupyter": { "source_hidden": true - }, - "tags": [] + } }, "outputs": [], "source": [ @@ -62,7 +57,7 @@ "\n", "import ampform\n", "import graphviz\n", - "import matplotlib\n", + "import matplotlib as mpl\n", "import matplotlib.pyplot as plt\n", "import numpy as np\n", "import qrules\n", @@ -90,7 +85,7 @@ "tf.get_logger().setLevel(\"WARNING\")\n", "warnings.filterwarnings(\"ignore\")\n", "\n", - "matplotlib.rcParams.update({\"font.size\": 14})\n", + "mpl.rcParams.update({\"font.size\": 14})\n", "np_config.enable_numpy_behavior()\n", "\n", "has_tf_gpu = bool(tf.config.list_physical_devices(\"GPU\"))\n", @@ -112,8 +107,7 @@ "metadata": { "jupyter": { "source_hidden": true - }, - "tags": [] + } }, "outputs": [], "source": [ @@ -211,8 +205,7 @@ "metadata": { "jupyter": { "source_hidden": true - }, - "tags": [] + } }, "outputs": [], "source": [ @@ -257,9 +250,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "tags": [] - }, + "metadata": {}, "outputs": [], "source": [ "expression = model.expression.doit()\n", @@ -294,8 +285,7 @@ "metadata": { "jupyter": { "source_hidden": true - }, - "tags": [] + } }, "outputs": [], "source": [ @@ -369,9 +359,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "tags": [] - }, + "metadata": {}, "outputs": [], "source": [ "free_parameters = {p for p in model.parameter_defaults if p.name in initial_parameters}\n", @@ -395,12 +383,10 @@ "metadata": {}, "outputs": [], "source": [ - "optimized_expression = optimized_expression.subs(\n", - " {\n", - " sp.Symbol(f\"m_{i}\", real=True): particle.mass\n", - " for i, particle in reaction.final_state.items()\n", - " }\n", - ")\n", + "optimized_expression = optimized_expression.subs({\n", + " sp.Symbol(f\"m_{i}\", real=True): particle.mass\n", + " for i, particle in reaction.final_state.items()\n", + "})\n", "sp.count_ops(optimized_expression)" ] }, @@ -486,9 +472,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "tags": [] - }, + "metadata": {}, "outputs": [], "source": [ "def cache_constant_sub_expressions(expression, free_symbols):\n", @@ -497,7 +481,7 @@ " cached_expression = cached_expressions[0]\n", " cse_dict = dict(cse)\n", " cse_symbols = set(cse_dict)\n", - " while any([bool(expr.free_symbols & cse_symbols) for expr in cse_dict.values()]):\n", + " while any(bool(expr.free_symbols & cse_symbols) for expr in cse_dict.values()):\n", " cse_dict = {\n", " symbol: expr.xreplace(cse_dict) for symbol, expr in cse_dict.items()\n", " }\n", @@ -512,9 +496,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "tags": [] - }, + "metadata": {}, "outputs": [], "source": [ "cached_expression, cse = cache_constant_sub_expressions(\n", @@ -529,8 +511,7 @@ "metadata": { "jupyter": { "source_hidden": true - }, - "tags": [] + } }, "outputs": [], "source": [ @@ -544,8 +525,7 @@ "metadata": { "jupyter": { "source_hidden": true - }, - "tags": [] + } }, "outputs": [], "source": [ @@ -559,8 +539,7 @@ "metadata": { "jupyter": { "source_hidden": true - }, - "tags": [] + } }, "outputs": [], "source": [ @@ -574,8 +553,7 @@ "metadata": { "jupyter": { "source_hidden": true - }, - "tags": [] + } }, "outputs": [], "source": [ @@ -586,9 +564,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "tags": [] - }, + "metadata": {}, "outputs": [], "source": [ "cache_converter = SympyDataTransformer.from_sympy(cse, backend=\"jax\")\n", @@ -606,9 +582,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "tags": [] - }, + "metadata": {}, "outputs": [], "source": [ "# Express expressions in backend\n", @@ -637,9 +611,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "tags": [] - }, + "metadata": {}, "outputs": [], "source": [ "estimator = UnbinnedNLL(function, data, phsp, backend=\"jax\")\n", @@ -650,9 +622,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "tags": [] - }, + "metadata": {}, "outputs": [], "source": [ "estimator = UnbinnedNLL(optimized_function, data_real, phsp_real, backend=\"jax\")\n", @@ -671,9 +641,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "tags": [] - }, + "metadata": {}, "outputs": [], "source": [ "estimator = UnbinnedNLL(cached_function, cached_data, cached_phsp, backend=\"jax\")\n", @@ -687,8 +655,7 @@ "metadata": { "jupyter": { "source_hidden": true - }, - "tags": [] + } }, "outputs": [], "source": [ @@ -709,8 +676,7 @@ "metadata": { "jupyter": { "source_hidden": true - }, - "tags": [] + } }, "outputs": [], "source": [ diff --git a/2021.12.13/tensorwaves-optimized-expression.ipynb b/2021.12.13/tensorwaves-optimized-expression.ipynb index 48d5609..5409029 100644 --- a/2021.12.13/tensorwaves-optimized-expression.ipynb +++ b/2021.12.13/tensorwaves-optimized-expression.ipynb @@ -24,9 +24,7 @@ }, { "cell_type": "markdown", - "metadata": { - "tags": [] - }, + "metadata": {}, "source": [ "## Install dependencies" ] @@ -34,9 +32,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "tags": [] - }, + "metadata": {}, "outputs": [], "source": [ "%pip install -q ampform[viz]==0.12.* tensorwaves[jax,pwa]==0.4.*" @@ -48,8 +44,7 @@ "metadata": { "jupyter": { "source_hidden": true - }, - "tags": [] + } }, "outputs": [], "source": [ @@ -62,7 +57,7 @@ "\n", "import ampform\n", "import graphviz\n", - "import matplotlib\n", + "import matplotlib as mpl\n", "import matplotlib.pyplot as plt\n", "import numpy as np\n", "import qrules\n", @@ -89,7 +84,7 @@ "tf.get_logger().setLevel(\"WARNING\")\n", "warnings.filterwarnings(\"ignore\")\n", "\n", - "matplotlib.rcParams.update({\"font.size\": 14})\n", + "mpl.rcParams.update({\"font.size\": 14})\n", "np_config.enable_numpy_behavior()\n", "\n", "has_tf_gpu = bool(tf.config.list_physical_devices(\"GPU\"))\n", @@ -111,8 +106,7 @@ "metadata": { "jupyter": { "source_hidden": true - }, - "tags": [] + } }, "outputs": [], "source": [ @@ -210,8 +204,7 @@ "metadata": { "jupyter": { "source_hidden": true - }, - "tags": [] + } }, "outputs": [], "source": [ @@ -256,9 +249,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "tags": [] - }, + "metadata": {}, "outputs": [], "source": [ "expression = model.expression.doit()\n", @@ -293,8 +284,7 @@ "metadata": { "jupyter": { "source_hidden": true - }, - "tags": [] + } }, "outputs": [], "source": [ @@ -361,9 +351,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "tags": [] - }, + "metadata": {}, "outputs": [], "source": [ "fixed_parameters = {\n", @@ -388,12 +376,10 @@ "metadata": {}, "outputs": [], "source": [ - "optimized_expression = optimized_expression.subs(\n", - " {\n", - " sp.Symbol(f\"m_{i}\", real=True): particle.mass\n", - " for i, particle in reaction.final_state.items()\n", - " }\n", - ")\n", + "optimized_expression = optimized_expression.subs({\n", + " sp.Symbol(f\"m_{i}\", real=True): particle.mass\n", + " for i, particle in reaction.final_state.items()\n", + "})\n", "sp.count_ops(optimized_expression)" ] }, @@ -499,9 +485,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "tags": [] - }, + "metadata": {}, "outputs": [], "source": [ "estimator = UnbinnedNLL(optimized_function, data_real, phsp_real, backend=\"jax\")\n", @@ -524,8 +508,7 @@ "metadata": { "jupyter": { "source_hidden": true - }, - "tags": [] + } }, "outputs": [], "source": [ @@ -546,8 +529,7 @@ "metadata": { "jupyter": { "source_hidden": true - }, - "tags": [] + } }, "outputs": [], "source": [ diff --git a/2021.12.13/tensorwaves.ipynb b/2021.12.13/tensorwaves.ipynb index 59ee2ec..57edec0 100644 --- a/2021.12.13/tensorwaves.ipynb +++ b/2021.12.13/tensorwaves.ipynb @@ -22,9 +22,7 @@ }, { "cell_type": "markdown", - "metadata": { - "tags": [] - }, + "metadata": {}, "source": [ "## Install dependencies" ] @@ -32,9 +30,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "tags": [] - }, + "metadata": {}, "outputs": [], "source": [ "%pip install -q ampform[viz]==0.12.* tensorwaves[jax,pwa]==0.4.*" @@ -46,8 +42,7 @@ "metadata": { "jupyter": { "source_hidden": true - }, - "tags": [] + } }, "outputs": [], "source": [ @@ -60,7 +55,7 @@ "\n", "import ampform\n", "import graphviz\n", - "import matplotlib\n", + "import matplotlib as mpl\n", "import matplotlib.pyplot as plt\n", "import numpy as np\n", "import qrules\n", @@ -87,7 +82,7 @@ "tf.get_logger().setLevel(\"WARNING\")\n", "warnings.filterwarnings(\"ignore\")\n", "\n", - "matplotlib.rcParams.update({\"font.size\": 14})\n", + "mpl.rcParams.update({\"font.size\": 14})\n", "np_config.enable_numpy_behavior()\n", "\n", "has_tf_gpu = bool(tf.config.list_physical_devices(\"GPU\"))\n", @@ -109,8 +104,7 @@ "metadata": { "jupyter": { "source_hidden": true - }, - "tags": [] + } }, "outputs": [], "source": [ @@ -208,8 +202,7 @@ "metadata": { "jupyter": { "source_hidden": true - }, - "tags": [] + } }, "outputs": [], "source": [ @@ -254,9 +247,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "tags": [] - }, + "metadata": {}, "outputs": [], "source": [ "expression = model.expression.doit()\n", @@ -291,8 +282,7 @@ "metadata": { "jupyter": { "source_hidden": true - }, - "tags": [] + } }, "outputs": [], "source": [ @@ -345,9 +335,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "tags": [] - }, + "metadata": {}, "outputs": [], "source": [ "function = create_parametrized_function(expression, parameter_defaults, backend=\"jax\")\n", @@ -372,8 +360,7 @@ "metadata": { "jupyter": { "source_hidden": true - }, - "tags": [] + } }, "outputs": [], "source": [ @@ -394,8 +381,7 @@ "metadata": { "jupyter": { "source_hidden": true - }, - "tags": [] + } }, "outputs": [], "source": [ diff --git a/README.md b/README.md index b07dcc2..51f0919 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ # ComPWA demo notebooks +[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff) [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier) [![Spelling checked](https://img.shields.io/badge/cspell-checked-brightgreen.svg)](https://github.com/streetsidesoftware/cspell/tree/master/packages/cspell) diff --git a/binder/requirements.txt b/binder/requirements.txt index e6626bd..04d18da 100644 --- a/binder/requirements.txt +++ b/binder/requirements.txt @@ -1,9 +1,5 @@ -# -# This file is autogenerated by pip-compile with Python 3.8 -# by the following command: -# -# pip-compile --no-annotate --strip-extras binder/requirements.in -# +# This file was autogenerated by uv via the following command: +# uv pip compile binder/requirements.in -o binder/requirements.txt --no-annotate --strip-extras asttokens==2.4.1 backcall==0.2.0 comm==0.2.2 @@ -11,31 +7,31 @@ contourpy==1.1.1 cycler==0.12.1 decorator==5.1.1 executing==2.0.1 -fonttools==4.51.0 +fonttools==4.53.1 importlib-resources==6.4.0 ipython==8.12.3 -ipywidgets==8.1.2 +ipywidgets==8.1.3 jedi==0.19.1 -jupyterlab-widgets==3.0.10 +jupyterlab-widgets==3.0.11 kiwisolver==1.4.5 matplotlib==3.7.5 -matplotlib-inline==0.1.6 +matplotlib-inline==0.1.7 numpy==1.24.4 -packaging==24.0 +packaging==24.1 parso==0.8.4 pexpect==4.9.0 pickleshare==0.7.5 -pillow==10.3.0 -prompt-toolkit==3.0.43 +pillow==10.4.0 +prompt-toolkit==3.0.47 ptyprocess==0.7.0 -pure-eval==0.2.2 -pygments==2.17.2 +pure-eval==0.2.3 +pygments==2.18.0 pyparsing==3.1.2 python-dateutil==2.9.0.post0 six==1.16.0 stack-data==0.6.3 -traitlets==5.14.2 -typing-extensions==4.11.0 +traitlets==5.14.3 +typing-extensions==4.12.2 wcwidth==0.2.13 -widgetsnbextension==4.0.10 -zipp==3.18.1 +widgetsnbextension==4.0.11 +zipp==3.19.2 diff --git a/pyproject.toml b/pyproject.toml index b79391c..3112dec 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,27 +1,82 @@ -[tool.black] -target-version = [ - "py36", - "py37", - "py38", - "py39", -] - -[tool.isort] -profile = "black" - -[tool.nbqa.addopts] -flake8 = [ - "--extend-ignore=E402,E501", -] - [tool.pytest.ini_options] addopts = [ + "--color=yes", "--durations=0", ] filterwarnings = [ "ignore:Passing a schema to Validator.iter_errors is deprecated.*:DeprecationWarning", ] +[tool.ruff] +extend-include = ["*.ipynb"] +preview = true +show-fixes = true +target-version = "py37" + +[tool.ruff.format] +docstring-code-format = true +line-ending = "lf" + +[tool.ruff.lint] +ignore = [ + "ANN401", + "COM812", + "CPY001", + "D101", + "D102", + "D103", + "D105", + "D107", + "D203", + "D213", + "D407", + "D416", + "DOC", + "E501", + "FURB101", + "FURB103", + "FURB140", + "G004", + "ISC001", + "PLW1514", + "PT001", + "PTH", + "SIM108", +] +select = ["ALL"] +task-tags = ["cspell"] + +[tool.ruff.lint.flake8-builtins] +builtins-ignorelist = ["display"] + +[tool.ruff.lint.flake8-comprehensions] +allow-dict-calls-with-keyword-arguments = true + +[tool.ruff.lint.isort] +split-on-trailing-comma = false + +[tool.ruff.lint.per-file-ignores] +"*.ipynb" = [ + "ANN", + "B018", + "C90", + "D", + "E303", + "E703", + "N806", + "N816", + "PLR09", + "PLR2004", + "PLW0602", + "PLW0603", + "S101", + "T20", + "TCH00", +] + +[tool.ruff.lint.pydocstyle] +convention = "google" + [tool.tomlsort] all = false ignore_case = true diff --git a/requirements.in b/requirements.in index 5939261..6ffe7cc 100644 --- a/requirements.in +++ b/requirements.in @@ -1,9 +1,8 @@ -c binder/requirements.txt -r binder/requirements.in -black -isort jupyterlab >=3 jupyterlab-code-formatter pre-commit +ruff tox ypy-websocket <0.8.3 # dependency conflict diff --git a/requirements.txt b/requirements.txt index 146beb9..15c1eef 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,141 +1,131 @@ -# -# This file is autogenerated by pip-compile with Python 3.8 -# by the following command: -# -# pip-compile --no-annotate --strip-extras requirements.in -# +# This file was autogenerated by uv via the following command: +# uv pip compile requirements.in -o requirements.txt --no-annotate --strip-extras aiofiles==22.1.0 aiosqlite==0.20.0 -anyio==4.3.0 +anyio==4.4.0 argon2-cffi==23.1.0 argon2-cffi-bindings==21.2.0 arrow==1.3.0 asttokens==2.4.1 async-lru==2.0.4 -attrs==23.2.0 -babel==2.14.0 +attrs==24.2.0 +babel==2.15.0 backcall==0.2.0 beautifulsoup4==4.12.3 -black==24.3.0 bleach==6.1.0 -cachetools==5.3.3 -certifi==2024.2.2 -cffi==1.16.0 +cachetools==5.4.0 +certifi==2024.7.4 +cffi==1.17.0 cfgv==3.4.0 chardet==5.2.0 charset-normalizer==3.3.2 -click==8.1.7 colorama==0.4.6 comm==0.2.2 contourpy==1.1.1 cycler==0.12.1 -debugpy==1.8.1 +debugpy==1.8.5 decorator==5.1.1 defusedxml==0.7.1 distlib==0.3.8 -exceptiongroup==1.2.0 +exceptiongroup==1.2.2 executing==2.0.1 -fastjsonschema==2.19.1 -filelock==3.13.3 -fonttools==4.51.0 +fastjsonschema==2.20.0 +filelock==3.15.4 +fonttools==4.53.1 fqdn==1.5.1 h11==0.14.0 httpcore==1.0.5 httpx==0.27.0 -identify==2.5.35 -idna==3.6 -importlib-metadata==7.1.0 +identify==2.6.0 +idna==3.7 +importlib-metadata==8.2.0 importlib-resources==6.4.0 -ipykernel==6.29.4 +ipykernel==6.29.5 ipython==8.12.3 -ipywidgets==8.1.2 +ipywidgets==8.1.3 isoduration==20.11.0 -isort==5.13.2 jedi==0.19.1 -jinja2==3.1.3 -json5==0.9.24 -jsonpointer==2.4 -jsonschema==4.21.1 +jinja2==3.1.4 +json5==0.9.25 +jsonpointer==3.0.0 +jsonschema==4.23.0 jsonschema-specifications==2023.12.1 -jupyter-client==8.6.1 +jupyter-client==8.6.2 jupyter-core==5.7.2 jupyter-events==0.10.0 -jupyter-lsp==2.2.4 -jupyter-server==2.13.0 +jupyter-lsp==2.2.5 +jupyter-server==2.14.2 jupyter-server-terminals==0.5.3 -jupyterlab==4.1.5 -jupyterlab-code-formatter==2.2.1 +jupyterlab==4.2.4 +jupyterlab-code-formatter==3.0.1 jupyterlab-pygments==0.3.0 -jupyterlab-server==2.25.4 -jupyterlab-widgets==3.0.10 +jupyterlab-server==2.27.3 +jupyterlab-widgets==3.0.11 kiwisolver==1.4.5 markupsafe==2.1.5 matplotlib==3.7.5 -matplotlib-inline==0.1.6 +matplotlib-inline==0.1.7 mistune==3.0.2 -mypy-extensions==1.0.0 nbclient==0.10.0 -nbconvert==7.16.3 +nbconvert==7.16.4 nbformat==5.10.4 nest-asyncio==1.6.0 -nodeenv==1.8.0 +nodeenv==1.9.1 notebook-shim==0.2.4 numpy==1.24.4 overrides==7.7.0 -packaging==24.0 +packaging==24.1 pandocfilters==1.5.1 parso==0.8.4 -pathspec==0.12.1 pexpect==4.9.0 pickleshare==0.7.5 -pillow==10.3.0 +pillow==10.4.0 pkgutil-resolve-name==1.3.10 -platformdirs==4.2.0 -pluggy==1.4.0 +platformdirs==4.2.2 +pluggy==1.5.0 pre-commit==3.5.0 prometheus-client==0.20.0 -prompt-toolkit==3.0.43 -psutil==5.9.8 +prompt-toolkit==3.0.47 +psutil==6.0.0 ptyprocess==0.7.0 -pure-eval==0.2.2 +pure-eval==0.2.3 pycparser==2.22 -pygments==2.17.2 +pygments==2.18.0 pyparsing==3.1.2 -pyproject-api==1.6.1 +pyproject-api==1.7.1 python-dateutil==2.9.0.post0 python-json-logger==2.0.7 pytz==2024.1 -pyyaml==6.0.1 -pyzmq==25.1.2 -referencing==0.34.0 -requests==2.31.0 +pyyaml==6.0.2 +pyzmq==26.1.0 +referencing==0.35.1 +requests==2.32.3 rfc3339-validator==0.1.4 rfc3986-validator==0.1.1 -rpds-py==0.18.0 -send2trash==1.8.2 +rpds-py==0.20.0 +ruff==0.5.6 +send2trash==1.8.3 +setuptools==72.1.0 six==1.16.0 sniffio==1.3.1 soupsieve==2.5 stack-data==0.6.3 terminado==0.18.1 -tinycss2==1.2.1 +tinycss2==1.3.0 tomli==2.0.1 -tornado==6.4 -tox==4.14.2 -traitlets==5.14.2 +tornado==6.4.1 +tox==4.17.0 +traitlets==5.14.3 types-python-dateutil==2.9.0.20240316 -typing-extensions==4.11.0 +typing-extensions==4.12.2 uri-template==1.3.0 -urllib3==2.2.1 -virtualenv==20.25.1 +urllib3==2.2.2 +virtualenv==20.26.3 wcwidth==0.2.13 -webcolors==1.13 +webcolors==24.6.0 webencodings==0.5.1 -websocket-client==1.7.0 -widgetsnbextension==4.0.10 +websocket-client==1.8.0 +widgetsnbextension==4.0.11 y-py==0.5.9 ypy-websocket==0.8.2 -zipp==3.18.1 - -# The following packages are considered to be unsafe in a requirements file: -# setuptools +zipp==3.19.2