Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ jobs:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
fetch-depth: 0
persist-credentials: false

- uses: hynek/build-and-inspect-python-package@efb823f52190ad02594531168b7a2d5790e66516 # v2.14.0

Expand Down
37 changes: 24 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,13 @@ jobs:
- name: Install uv
uses: astral-sh/setup-uv@85856786d1ce8acfbcc2f13a5f3fbd6b938f9f41 # v7.1.2

- name: Install the project
run: uv sync --group nox
- name: Install
run: uv sync --no-default-groups --group nox --group lint --locked

- uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1
with:
extra_args: --hook-stage manual --all-files
- name: Lint
run: uv run --frozen nox -s lint

checks:
tests:
name: Check Python ${{ matrix.python-version }} on ${{ matrix.runs-on }}
runs-on: ${{ matrix.runs-on }}
needs: [format]
Expand All @@ -53,10 +52,12 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Run tests
run: >-
uv run --group test pytest --cov --cov-report=xml --cov-report=term
--durations=20
- name: Install
run: uv sync --no-default-groups --group nox --group test --locked

- name: Test package
run: |
uv run --frozen nox -s test -- --cov --cov-report=xml --cov-report=term --durations=20

- name: Upload coverage report
uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # v5.5.1
Expand All @@ -82,11 +83,21 @@ jobs:
python-version: ${{ matrix.python-version }}

- name: Run tests
run: >-
uv run --group test --resolution lowest pytest --cov --cov-report=xml
--cov-report=term --durations=20
run: |
uv run --group test --resolution lowest pytest --cov --cov-report=xml --cov-report=term --durations=20

- name: Upload coverage report
uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # v5.5.1
with:
token: ${{ secrets.CODECOV_TOKEN }}

status:
name: CI Pass
runs-on: ubuntu-latest
needs: [format, tests, check_oldest]
if: always()
steps:
- name: All required jobs passed
uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}
16 changes: 2 additions & 14 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,24 +50,12 @@ repos:
args: ["--fix", "--show-fixes"]
- id: ruff-format

- repo: https://github.com/pre-commit/mirrors-mypy
rev: "v1.18.2"
hooks:
- id: mypy
files: src
args: []
additional_dependencies:
- diffrax
- equinox
- jaxtyping
- numpy
- plum-dispatch

- repo: https://github.com/codespell-project/codespell
rev: "v2.4.1"
hooks:
- id: codespell
args: [--skip=uv.lock]
args: ["--toml", "pyproject.toml"]
additional_dependencies: ["tomli"]

- repo: https://github.com/shellcheck-py/shellcheck-py
rev: "v0.11.0.1"
Expand Down
81 changes: 38 additions & 43 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -1,82 +1,77 @@
"""Nox configuration."""
"""Nox setup."""

import shutil
from pathlib import Path

import nox

DIR = Path(__file__).parent.resolve()
from nox_uv import session

nox.needs_version = ">=2024.3.2"
nox.options.sessions = ["lint", "tests"]
nox.options.default_venv_backend = "uv|virtualenv"

nox.options.default_venv_backend = "uv"

@nox.session
def check(session: nox.Session, /) -> None:
"""Run all checks."""
lint(session)
test(session)
DIR = Path(__file__).parent.resolve()


# =============================================================================
# Linting


@nox.session
def lint(session: nox.Session, /) -> None:
@session(uv_groups=["lint"], reuse_venv=True)
def lint(s: nox.Session, /) -> None:
"""Run the linter."""
precommit(session)
pylint(session)
s.notify("precommit")
s.notify("pylint")
s.notify("mypy")


@nox.session
def precommit(session: nox.Session, /) -> None:
@session(uv_groups=["lint"], reuse_venv=True)
def precommit(s: nox.Session, /) -> None:
"""Run the pre-commit hooks."""
session.run(
"uv",
"run",
"pre-commit",
"run",
"--all-files",
"--show-diff-on-failure",
*session.posargs,
)


@nox.session
def pylint(session: nox.Session, /) -> None:
s.run("pre-commit", "run", "--all-files", *s.posargs)


@session(uv_groups=["lint"], reuse_venv=True)
def pylint(s: nox.Session, /) -> None:
"""Run PyLint."""
# This needs to be installed into the package environment, and is slower
# than a pre-commit check
session.run("uv", "sync", "--group", "lint")
session.run("uv", "run", "pylint", "src", *session.posargs)
s.run("pylint", "src", *s.posargs)


@session(uv_groups=["lint"], reuse_venv=True)
def mypy(s: nox.Session, /) -> None:
"""Run mypy."""
s.run("mypy", "src", *s.posargs)


# =============================================================================
# Testing


@nox.session
def test(session: nox.Session, /) -> None:
@session(uv_groups=["test"], reuse_venv=True)
def test(s: nox.Session, /) -> None:
"""Run the tests."""
s.notify("pytest", posargs=s.posargs)


@session(uv_groups=["test"], reuse_venv=True)
def pytest(s: nox.Session, /) -> None:
"""Run the tests."""
session.run("uv", "sync", "--group", "test")
session.run("uv", "run", "pytest", *session.posargs)
s.run("pytest", *s.posargs)


# =============================================================================
# Packaging


@nox.session
@session(uv_groups=["build"])
def rm_build(_: nox.Session, /) -> None:
"""Remove the build directory."""
build_path = DIR.joinpath("build")
if build_path.exists():
shutil.rmtree(build_path)


@nox.session
def build(session: nox.Session, /) -> None:
@session(uv_groups=["build"])
def build(s: nox.Session, /) -> None:
"""Build an SDist and wheel."""
rm_build(session)
session.run("uv", "build", *session.posargs)
rm_build(s)
s.run("python", "-m", "build")
93 changes: 52 additions & 41 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,22 @@
dev = [
"ipykernel>=6.29.5",
"cz-conventional-gitmoji>=0.6.1",
{include-group = "build"},
{include-group = "lint"},
{include-group = "nox"},
{include-group = "test"},
]
build = [
"build>=1.3.0",
]
lint = [
"pre-commit>=4.1.0",
"pylint>=3.3.8",
"mypy>=1.19.0",
"pre-commit>=4.1.0",
"pylint>=3.3.8",
]
nox = [
"nox>=2024.10.9",
"nox>=2024.10.9",
"nox-uv>=0.6.3",
]
test = [
"attrs>=25.3.0",
Expand All @@ -72,33 +78,12 @@ version.source = "vcs"
build.hooks.vcs.version-file = "src/diffraxtra/_version.py"


[tool.commitizen]
name = "cz_gitmoji"
[tool.codespell]
skip = ["uv.lock"]


[tool.pytest.ini_options]
minversion = "8.3"
addopts = [
"--showlocals",
"--strict-config",
"--strict-markers",
"-p no:doctest", # using sybil
"-ra",
]
xfail_strict = true
filterwarnings = [
"error",
"ignore:jax.core.Primitive is deprecated:DeprecationWarning",
"ignore:jax.core.pp_eqn_rules is deprecated:DeprecationWarning",
# Equinox 0.11.5 & Jax 0.4.35
"ignore:jax.interpreters.batching.NotMapped is deprecated:DeprecationWarning",
]
log_cli_level = "INFO"
testpaths = ["README.md", "src/", "tests/"]
norecursedirs = [
".*", # ignores .hypothesis, .git, etc.
"__pycache__"
]
[tool.commitizen]
name = "cz_gitmoji"


[tool.coverage]
Expand Down Expand Up @@ -129,6 +114,44 @@ ignore_missing_imports = true
module = ["plum.*"]


[tool.pylint]
py-version = "3.11"
ignore-paths = [".*/_version.py"]
reports.output-format = "colorized"
similarities.ignore-imports = "yes"
disable = [
"fixme",
"function-redefined", # incompatible with plum-dispatch
"line-too-long", # handled by ruff
"no-member", # handled by mypy
]


[tool.pytest.ini_options]
minversion = "8.3"
addopts = [
"--showlocals",
"--strict-config",
"--strict-markers",
"-p no:doctest", # using sybil
"-ra",
]
xfail_strict = true
filterwarnings = [
"error",
"ignore:jax.core.Primitive is deprecated:DeprecationWarning",
"ignore:jax.core.pp_eqn_rules is deprecated:DeprecationWarning",
# Equinox 0.11.5 & Jax 0.4.35
"ignore:jax.interpreters.batching.NotMapped is deprecated:DeprecationWarning",
]
log_cli_level = "INFO"
testpaths = ["README.md", "src/", "tests/"]
norecursedirs = [
".*", # ignores .hypothesis, .git, etc.
"__pycache__"
]


[tool.ruff]
src = ["src"]

Expand Down Expand Up @@ -168,19 +191,6 @@ src = ["src"]
"numpy" = "np"


[tool.pylint]
py-version = "3.11"
ignore-paths = [".*/_version.py"]
reports.output-format = "colorized"
similarities.ignore-imports = "yes"
disable = [
"fixme",
"function-redefined", # incompatible with plum-dispatch
"line-too-long", # handled by ruff
"no-member", # handled by mypy
]


[tool.uv]
constraint-dependencies = [
# Because IPyKernel doesn't constrain its dependencies
Expand All @@ -198,6 +208,7 @@ constraint-dependencies = [
# Misc
"opt-einsum>=3.3.0",
# Transitive dependencies for --resolution lowest
"pyparsing>3.0.0",
"future>=0.16.0",
"backcall>=0.1.0",
"wcwidth>=0.1.0",
Expand Down
4 changes: 2 additions & 2 deletions src/diffraxtra/_src/diffeq_abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
default_throw = params["throw"].default


class AbstractDiffEqSolver(eqx.Module, strict=True):
class AbstractDiffEqSolver(eqx.Module):
"""Class-based interface for solving differential equations.

This is a convenience wrapper around `diffrax.diffeqsolve`, allowing for
Expand Down Expand Up @@ -177,7 +177,7 @@ def from_(
# ==========================================================


@AbstractDiffEqSolver.__call__.dispatch # type: ignore[attr-defined,misc]
@AbstractDiffEqSolver.__call__.dispatch # type: ignore[attr-defined,untyped-decorator]
@ft.partial(eqx.filter_jit)
def call(self: "AbstractDiffEqSolver", terms: Any, /, **kwargs: Any) -> dfx.Solution:
"""Solve a differential equation, with keyword arguments."""
Expand Down
Loading
Loading