Skip to content

Commit

Permalink
FIX: define dev dependencies as dependency groups (#441)
Browse files Browse the repository at this point in the history
* BREAK: remove `all` optional depdency
* DX: run `pyright` in `tox -e sty` job
* MAINT: update links to TRs
* MAINT: update lock files
  • Loading branch information
redeboer authored Oct 28, 2024
1 parent 608c08c commit 8cfff67
Show file tree
Hide file tree
Showing 20 changed files with 396 additions and 487 deletions.
6 changes: 4 additions & 2 deletions .binder/postBuild
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ set -ex
curl -LsSf https://astral.sh/uv/install.sh | sh
source $HOME/.cargo/env
uv export \
--extra jupyter \
--extra notebooks \
--group jupyter \
--group notebooks \
--no-dev \
> requirements.txt
uv pip install \
--requirement requirements.txt \
--system
rm requirements.txt
uv cache clean
5 changes: 3 additions & 2 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ jobs:
- name: Run pytest-benchmark
run: |
uv run \
--extra all \
--extra test \
--all-extras \
--group test \
--no-dev \
${{ steps.with.outputs.packages }} \
pytest \
-k benchmark \
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-qrules-v0.9.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ jobs:
- name: Run pytest with QRules v0.9
run: |
uv run \
--extra test \
--group test \
--with qrules~=0.9.0 \
pytest --numprocesses auto
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ on:

jobs:
doc:
uses: ComPWA/actions/.github/workflows/ci-docs.yml@v2
uses: ComPWA/actions/.github/workflows/ci-docs.yml@v2.1
permissions:
pages: write
id-token: write
Expand All @@ -37,7 +37,7 @@ jobs:
python-version: "3.11"
specific-pip-packages: ${{ inputs.specific-pip-packages }}
pytest:
uses: ComPWA/actions/.github/workflows/pytest.yml@v2
uses: ComPWA/actions/.github/workflows/pytest.yml@v2.1
with:
coverage-target: ampform
macos-python-version: "3.9"
Expand All @@ -46,6 +46,6 @@ jobs:
if: inputs.specific-pip-packages == ''
secrets:
token: ${{ secrets.PAT }}
uses: ComPWA/actions/.github/workflows/pre-commit.yml@v2
uses: ComPWA/actions/.github/workflows/pre-commit.yml@v2.1
with:
python-version: "3.11"
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ repos:
- id: check-useless-excludes

- repo: https://github.com/ComPWA/policy
rev: 0.5.0
rev: 0.5.5
hooks:
- id: check-dev-files
args:
Expand Down Expand Up @@ -61,7 +61,7 @@ repos:
metadata.vscode
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.0
rev: v0.7.1
hooks:
- id: ruff
args: [--fix]
Expand Down Expand Up @@ -128,7 +128,7 @@ repos:
pass_filenames: false

- repo: https://github.com/streetsidesoftware/cspell-cli
rev: v8.15.1
rev: v8.15.2
hooks:
- id: cspell

Expand All @@ -154,11 +154,11 @@ repos:
- python

- repo: https://github.com/ComPWA/pyright-pre-commit
rev: v1.1.385
rev: v1.1.386
hooks:
- id: pyright

- repo: https://github.com/astral-sh/uv-pre-commit
rev: 0.4.24
rev: 0.4.27
hooks:
- id: uv-lock
6 changes: 5 additions & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ build:
pixi global install graphviz uv
- |-
export UV_LINK_MODE=copy
uv run --extra doc --locked --with tox \
uv run \
--group doc \
--locked \
--no-dev \
--with tox \
tox -e doc
mkdir -p $READTHEDOCS_OUTPUT
mv docs/_build/html $READTHEDOCS_OUTPUT
22 changes: 20 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,30 @@ cd ampform
Now it's simply a matter of creating and activating the [virtual environment](https://docs.astral.sh/uv/pip/environments) with [`uv sync`](https://docs.astral.sh/uv/reference/cli/#uv-sync). The dependencies for the project are 'pinned' in each commit through the [`uv.lock` file](https://docs.astral.sh/uv/concepts/projects/#project-lockfile).

```shell
uv sync
uv sync --all-extras
source .venv/bin/activate
```

Formatting and linting checks are automatically performed when committing changes. This is done with [pre-commit](https://pre-commit.com). To install the hooks in your local repository, run [`pre-commit install`](https://pre-commit.com/#3-install-the-git-hook-scripts) **once**:
Formatting and linting checks are automatically performed when committing changes. This is done with [pre-commit](https://pre-commit.com). To install the hooks in your local repository, run install `pre-commit` with `uv`:

```shell
uv tool install pre-commit --with pre-commit-uv --force-reinstall
```

and [`pre-commit install`](https://pre-commit.com/#3-install-the-git-hook-scripts) **once**:

```shell
pre-commit install --install-hooks
```

In addition, it may be handy to install `tox`:

```shell
uv tool install tox --with tox-uv
```

If the repository provides a Tox configuration under [`pyproject.toml`](./pyproject.toml), you can see which jobs it defines with:

```shell
tox list
```
2 changes: 1 addition & 1 deletion docs/_extend_docstrings.py
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ def extend_chew_mandelstam_s_wave() -> None:
with :math:`q^2(s)` defined as :eq:`BreakupMomentumSquared`.
.. seealso:: :doc:`compwa-report:003`
.. seealso:: :doc:`compwa-report:003/index`
""",
)

Expand Down
1 change: 1 addition & 0 deletions docs/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ python3 -m pip install git+https://github.com/ComPWA/ampform@main

:::{include} ../CONTRIBUTING.md
:start-after: **[compwa.github.io/develop](https://compwa.github.io/develop)**!
:end-before: If the repository provides a Tox configuration
:::

That's all! Have a look at {doc}`/usage` to try out the package. You can also have a look at {doc}`compwa:develop` for tips on how to work with this 'editable' developer setup!
2 changes: 1 addition & 1 deletion docs/usage/dynamics/analytic-continuation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"source": [
":::{note}\n",
"\n",
"Improvements to analytic continuation in AmpForm are currently being developed in {doc}`compwa-report:003` and {doc}`compwa-report:004`.\n",
"Improvements to analytic continuation in AmpForm are currently being developed in {doc}`compwa-report:003/index` and {doc}`compwa-report:004/index`.\n",
"\n",
":::"
]
Expand Down
4 changes: 2 additions & 2 deletions docs/usage/dynamics/k-matrix.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
"\n",
":::{note}\n",
"\n",
"The $\\boldsymbol{K}$-matrix approach was originally worked worked out in {doc}`compwa-report:005`, {doc}`compwa-report:009`, and {doc}`compwa-report:010`. Those reports contained a few mistakes, which have been addressed here.\n",
"The $\\boldsymbol{K}$-matrix approach was originally worked worked out in {doc}`compwa-report:005/index`, {doc}`compwa-report:009/index`, and {doc}`compwa-report:010/index`. Those reports contained a few mistakes, which have been addressed here.\n",
"\n",
":::\n",
"\n",
Expand Down Expand Up @@ -331,7 +331,7 @@
"\\end{eqnarray}\n",
"$$ (K-hat-and-T-hat)\n",
"\n",
"[^rho-dagger]: An unpublished primer on the $\\boldsymbol{K}$-matrix by Chung {cite}`chungPrimerKmatrixFormalism1995` uses a conjugate transpose of $\\boldsymbol{\\rho}$, e.g. $\\boldsymbol{T} = \\sqrt{\\boldsymbol{\\rho^\\dagger}} \\; \\boldsymbol{\\hat{T}} \\sqrt{\\boldsymbol{\\rho}}$. This should not matter above threshold, where the phase space factor is real, but could have effects below threshold. This is where things become tricky: on the one hand, we need to ensure that $\\boldsymbol{K}$ remains real (unitarity) and on the other, we need to take keep track of which imaginary square root we choose (**Riemann sheet**). The latter is often called the requirement of **analyticity**. This is currently being explored in {doc}`compwa-report:003` and {doc}`compwa-report:004`.\n",
"[^rho-dagger]: An unpublished primer on the $\\boldsymbol{K}$-matrix by Chung {cite}`chungPrimerKmatrixFormalism1995` uses a conjugate transpose of $\\boldsymbol{\\rho}$, e.g. $\\boldsymbol{T} = \\sqrt{\\boldsymbol{\\rho^\\dagger}} \\; \\boldsymbol{\\hat{T}} \\sqrt{\\boldsymbol{\\rho}}$. This should not matter above threshold, where the phase space factor is real, but could have effects below threshold. This is where things become tricky: on the one hand, we need to ensure that $\\boldsymbol{K}$ remains real (unitarity) and on the other, we need to take keep track of which imaginary square root we choose (**Riemann sheet**). The latter is often called the requirement of **analyticity**. This is currently being explored in {doc}`compwa-report:003/index` and {doc}`compwa-report:004/index`.\n",
"\n",
"With these definitions, we can deduce that:\n",
"\n",
Expand Down
4 changes: 2 additions & 2 deletions docs/usage/helicity/spin-alignment.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"As described in {doc}`compwa-report:015`, the {doc}`'standard' helicity formalism </usage/helicity/formalism>` is not suited for state transitions that have different decay topologies. For this reason, the {class}`.HelicityAmplitudeBuilder` can insert a number of Wigner-$D$ functions into the amplitude model to 'align' the final state spins of underlying {class}`~qrules.topology.Topology` instances in the full decay.\n",
"As described in {doc}`compwa-report:015/index`, the {doc}`'standard' helicity formalism </usage/helicity/formalism>` is not suited for state transitions that have different decay topologies. For this reason, the {class}`.HelicityAmplitudeBuilder` can insert a number of Wigner-$D$ functions into the amplitude model to 'align' the final state spins of underlying {class}`~qrules.topology.Topology` instances in the full decay.\n",
"\n",
"Imagine we have the following the decay:"
]
Expand Down Expand Up @@ -388,7 +388,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"For more information about these angles, see {ref}`compwa-report:015:Compute Wigner rotation angles` in {doc}`TR-015 <compwa-report:015>`."
"For more information about these angles, see {ref}`compwa-report:015/index:Compute Wigner rotation angles` in {doc}`TR-015 <compwa-report:015/index>`."
]
}
],
Expand Down
4 changes: 2 additions & 2 deletions docs/usage/kinematics.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@
"metadata": {},
"source": [
":::{margin}\n",
"This notebook originates from {doc}`compwa-report:017`.\n",
"This notebook originates from {doc}`compwa-report:017/index`.\n",
":::\n",
"\n",
"Kinematics for a three-body decay $0 \\to 123$ can be fully described by two **Mandelstam variables** $\\sigma_1, \\sigma_2$, because the third variable $\\sigma_3$ can be expressed in terms $\\sigma_1, \\sigma_2$, the mass $m_0$ of the initial state, and the masses $m_1, m_2, m_3$ of the final state. As can be seen, the roles of $\\sigma_1, \\sigma_2, \\sigma_3$ are interchangeable.\n",
Expand Down Expand Up @@ -384,7 +384,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"See {doc}`compwa-report:017` for an interactive visualization of the phase space region and an analytic expression for the phase space boundary."
"See {doc}`compwa-report:017/index` for an interactive visualization of the phase space region and an analytic expression for the phase space boundary."
]
}
],
Expand Down
58 changes: 27 additions & 31 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,29 @@ name = "ampform"
requires-python = ">=3.9"

[project.optional-dependencies]
all = [
"ampform[scipy]",
"ampform[viz]",
]
scipy = ["scipy"]
viz = ["graphviz"]

[project.readme]
content-type = "text/markdown"
file = "README.md"

[project.urls]
Changelog = "https://github.com/ComPWA/ampform/releases"
Documentation = "https://ampform.rtfd.io"
Source = "https://github.com/ComPWA/ampform"
Tracker = "https://github.com/ComPWA/ampform/issues"

[dependency-groups]
dev = [
"ampform[all]",
"ampform[doc]",
"ampform[jupyter]",
"ampform[sty]",
"ampform[test]",
"ruff",
"sphinx-autobuild",
"tox",
{include-group = "doc"},
{include-group = "jupyter"},
{include-group = "style"},
{include-group = "test"},
]
doc = [
"ampform[notebooks]",
"myst-nb",
"sphinx",
"sphinx-api-relink >=0.0.4",
Expand All @@ -74,18 +82,20 @@ doc = [
"sphinx-thebe",
"sphinx-togglebutton",
"sphinxcontrib-bibtex >=2",
{include-group = "notebooks"},
]
jupyter = [
"jupyterlab",
"jupyterlab-code-formatter >=3.0.0",
"jupyterlab-code-formatter",
"jupyterlab-git",
"jupyterlab-lsp",
"jupyterlab-myst",
"python-lsp-ruff",
"python-lsp-server[rope]",
]
notebooks = [
"ampform[all]",
"ampform[scipy,viz]",
"black",
"ipympl",
"matplotlib <3.9.0", # https://github.com/ComPWA/ampform/issues/279
Expand All @@ -94,12 +104,9 @@ notebooks = [
"numpy",
"rich",
]
scipy = ["scipy"]
sty = [
"ampform[types]",
style = [
"mypy >=0.730",
"pre-commit-uv",
"ruff",
{include-group = "types"},
]
test = [
"ampform[scipy]",
Expand All @@ -120,17 +127,6 @@ types = [
"pytest-benchmark",
"sphinx-api-relink >=0.0.3",
]
viz = ["graphviz"]

[project.readme]
content-type = "text/markdown"
file = "README.md"

[project.urls]
Changelog = "https://github.com/ComPWA/ampform/releases"
Documentation = "https://ampform.rtfd.io"
Source = "https://github.com/ComPWA/ampform"
Tracker = "https://github.com/ComPWA/ampform/issues"

[tool.setuptools]
include-package-data = false
Expand Down Expand Up @@ -235,6 +231,8 @@ reportUnusedFunction = true
reportUnusedImport = true
reportUnusedVariable = true
typeCheckingMode = "strict"
venv = ".venv"
venvPath = "."

[tool.pytest.ini_options]
addopts = [
Expand Down Expand Up @@ -568,10 +566,8 @@ description = Run all notebooks with pytest
allowlist_externals =
pre-commit
commands =
pre-commit run {posargs} --all-files
pre-commit run --all-files {posargs}
description = Perform all linting, formatting, and spelling checks
setenv =
SKIP = pyright
"""

[tool.uv]
Expand Down
4 changes: 2 additions & 2 deletions src/ampform/dynamics/form_factor.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class BlattWeisskopfSquared(sp.Expr):
:pdg-review:`2021; Resonances; p.9`. We normalize the form factor such that
:math:`B_L^2(1)=1` and that :math:`B_L^2` is unitless no matter what :math:`z` is.
.. seealso:: :ref:`usage/dynamics:Form factor`, :doc:`TR-029<compwa-report:029>`,
.. seealso:: :ref:`usage/dynamics:Form factor`, :doc:`TR-029<compwa-report:029/index>`,
and :cite:`chungFormulasAngularMomentumBarrier2015`.
With this, the implementation becomes
Expand Down Expand Up @@ -94,7 +94,7 @@ def _formulate_blatt_weisskopf(ell, z) -> sp.Expr:
class SphericalHankel1(sp.Expr):
r"""Spherical Hankel function of the first kind for real-valued :math:`z`.
See :cite:`VonHippel:1972fg`, Equation (A12), and :doc:`TR-029<compwa-report:029>`
See :cite:`VonHippel:1972fg`, Equation (A12), and :doc:`TR-029<compwa-report:029/index>`
for more info. `This page
<https://mathworld.wolfram.com/SphericalHankelFunctionoftheFirstKind.html>`_
explains the difference with the *general* Hankel function of the first kind,
Expand Down
4 changes: 2 additions & 2 deletions src/ampform/dynamics/kmatrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
.. seealso:: :doc:`/usage/dynamics/k-matrix`.
This module is an implementation of :doc:`compwa-report:005`,
:doc:`compwa-report:009`, and :doc:`compwa-report:010`. It works with classes to
This module is an implementation of :doc:`compwa-report:005/index`,
:doc:`compwa-report:009/index`, and :doc:`compwa-report:010/index`. It works with classes to
keep the code organized and to enable caching of the matrix multiplications, but this
might change once these dynamics are implemented into the amplitude builder.
"""
Expand Down
2 changes: 1 addition & 1 deletion src/ampform/sympy/deprecated.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class UnevaluatedExpression(sp.Expr):
1. condense the LaTeX representation of an expression tree by providing a custom
:meth:`_latex` method.
2. overwrite its printer methods (see `.NumPyPrintable` and e.g.
:doc:`compwa-report:001`).
:doc:`compwa-report:001/index`).
The `UnevaluatedExpression` base class makes implementations of its derived classes
more secure by enforcing the developer to provide implementations for these methods,
Expand Down
2 changes: 1 addition & 1 deletion src/ampform/sympy/math.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class ComplexSqrt(NumPyPrintable):
A special version :func:`~sympy.functions.elementary.miscellaneous.sqrt` that
renders nicely as LaTeX and and can be used as a handle for lambdify printers. See
:doc:`compwa-report:000`, :doc:`compwa-report:001`, and
:doc:`compwa-report:000/index`, :doc:`compwa-report:001/index`, and
:doc:`sympy:modules/printing` for how to implement a custom
:func:`~sympy.utilities.lambdify.lambdify` printer.
"""
Expand Down
Loading

0 comments on commit 8cfff67

Please sign in to comment.