Skip to content

Commit

Permalink
Update the pre-commit hook (and fix deprecations) to modernise probdi…
Browse files Browse the repository at this point in the history
…ffeq's CI (#742)
  • Loading branch information
pnkraemer authored Jun 10, 2024
1 parent 5de58b8 commit 370ea81
Show file tree
Hide file tree
Showing 66 changed files with 69 additions and 30 deletions.
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ default_language_version:
python: python3
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v4.6.0
hooks:
- id: end-of-file-fixer
- id: check-merge-conflict
Expand All @@ -13,15 +13,15 @@ repos:
- id: yamlfix
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.1.9
rev: v0.4.8
hooks:
# Run the linter.
- id: ruff
args: [--fix]
# Run the formatter.
- id: ruff-format
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.8.0
rev: v1.10.0
hooks:
- id: mypy
args: [--ignore-missing-imports]
1 change: 1 addition & 0 deletions docs/benchmarks/hires/run_hires.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
See makefile for instructions.
"""

import argparse
import functools
import os
Expand Down
1 change: 1 addition & 0 deletions docs/benchmarks/lotkavolterra/run_lotkavolterra.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
See makefile for instructions.
"""

import argparse
import functools
import os
Expand Down
1 change: 1 addition & 0 deletions docs/benchmarks/pleiades/run_pleiades.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
See makefile for instructions.
"""

import argparse
import functools
import os
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
See makefile for instructions.
"""

import argparse
import functools
import os
Expand Down
1 change: 1 addition & 0 deletions docs/benchmarks/taylor_node/run_taylor_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
See makefile for instructions.
"""

import argparse
import functools
import os
Expand Down
1 change: 1 addition & 0 deletions docs/benchmarks/taylor_pleiades/run_taylor_pleiades.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
See makefile for instructions.
"""

import argparse
import functools
import os
Expand Down
1 change: 1 addition & 0 deletions docs/benchmarks/vanderpol/run_vanderpol.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
See makefile for instructions.
"""

import argparse
import functools
import os
Expand Down
1 change: 1 addition & 0 deletions docs/examples_parameter_estimation/neural_ode.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

# +
"""Train a neural ODE with ProbDiffEq and Optax."""

import jax
import jax.numpy as jnp
import matplotlib.pyplot as plt
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

# +
"""Demonstrate how probabilistic solvers work via conditioning on constraints."""

import jax
import jax.numpy as jnp
import matplotlib.pyplot as plt
Expand Down
1 change: 1 addition & 0 deletions probdiffeq/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
"""Probabilistic solvers for differential equations."""

from probdiffeq._version import version as __version__ # noqa: F401
1 change: 1 addition & 0 deletions probdiffeq/adaptive.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Adaptive solvers for initial value problems (IVPs)."""

from probdiffeq import controls
from probdiffeq.backend import containers, control_flow, functools, linalg, tree_util
from probdiffeq.backend import numpy as np
Expand Down
1 change: 0 additions & 1 deletion probdiffeq/backend/abc.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Abstract base classes."""


import abc


Expand Down
1 change: 1 addition & 0 deletions probdiffeq/backend/functools.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Function transformation tools."""

import functools

import jax
Expand Down
1 change: 1 addition & 0 deletions probdiffeq/backend/ode.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""ODE stuff."""

import diffeqzoo.ivps
import diffrax
import jax
Expand Down
1 change: 1 addition & 0 deletions probdiffeq/backend/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
have been very inconsistent.
This is not good for extendability of the test suite.
"""

import jax.numpy as jnp
import jax.tree_util
import pytest
Expand Down
1 change: 1 addition & 0 deletions probdiffeq/backend/warnings.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Warnings."""

import warnings


Expand Down
1 change: 1 addition & 0 deletions probdiffeq/impl/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""State-space model implementations."""

from probdiffeq.impl import _impl

impl = _impl.Impl()
Expand Down
1 change: 1 addition & 0 deletions probdiffeq/impl/_conditional.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Conditionals."""

from probdiffeq.backend import abc


Expand Down
1 change: 1 addition & 0 deletions probdiffeq/impl/_impl.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""State-space model impl."""

import warnings

from probdiffeq.backend import abc
Expand Down
1 change: 1 addition & 0 deletions probdiffeq/impl/blockdiag/_conditional.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Conditional implementation."""

from probdiffeq.backend import functools
from probdiffeq.backend import numpy as np
from probdiffeq.impl import _conditional
Expand Down
1 change: 1 addition & 0 deletions probdiffeq/impl/blockdiag/_linearise.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Linearisation."""

from probdiffeq.impl import _linearise
from probdiffeq.util import linop_util

Expand Down
1 change: 1 addition & 0 deletions probdiffeq/impl/blockdiag/_ssm_util.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""State-space model utilities."""

from probdiffeq.backend import functools
from probdiffeq.backend import numpy as np
from probdiffeq.impl import _ssm_util
Expand Down
1 change: 1 addition & 0 deletions probdiffeq/impl/blockdiag/_transform.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Random-variable transformation."""

from probdiffeq.backend import functools
from probdiffeq.backend import numpy as np
from probdiffeq.impl import _transform
Expand Down
1 change: 1 addition & 0 deletions probdiffeq/impl/blockdiag/factorised_impl.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Factorisations."""

from probdiffeq.impl import _impl
from probdiffeq.impl.blockdiag import (
_conditional,
Expand Down
1 change: 1 addition & 0 deletions probdiffeq/impl/dense/_conditional.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Conditional implementation."""

from probdiffeq.impl import _conditional
from probdiffeq.impl.dense import _normal
from probdiffeq.util import cholesky_util, cond_util
Expand Down
1 change: 0 additions & 1 deletion probdiffeq/impl/dense/_linearise.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Linearisation."""


from probdiffeq.backend import functools
from probdiffeq.backend import numpy as np
from probdiffeq.impl import _linearise
Expand Down
1 change: 1 addition & 0 deletions probdiffeq/impl/dense/_transform.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Random variable transformations."""

from probdiffeq.backend import containers
from probdiffeq.backend.typing import Array, Callable
from probdiffeq.impl import _transform
Expand Down
1 change: 1 addition & 0 deletions probdiffeq/impl/dense/factorised_impl.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""API for dense factorisations."""

from probdiffeq.impl import _impl
from probdiffeq.impl.dense import (
_conditional,
Expand Down
1 change: 1 addition & 0 deletions probdiffeq/impl/isotropic/_linearise.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Linearisation."""

from probdiffeq.impl import _linearise
from probdiffeq.util import linop_util

Expand Down
1 change: 1 addition & 0 deletions probdiffeq/impl/isotropic/_ssm_util.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""State-space model utilities."""

from probdiffeq.backend import numpy as np
from probdiffeq.impl import _ssm_util
from probdiffeq.impl.isotropic import _normal
Expand Down
1 change: 1 addition & 0 deletions probdiffeq/impl/isotropic/factorised_impl.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Isotropic factorisation."""

from probdiffeq.impl import _impl
from probdiffeq.impl.isotropic import (
_conditional,
Expand Down
1 change: 1 addition & 0 deletions probdiffeq/impl/scalar/_conditional.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Conditionals."""

from probdiffeq.backend import linalg
from probdiffeq.backend import numpy as np
from probdiffeq.impl import _conditional
Expand Down
1 change: 1 addition & 0 deletions probdiffeq/impl/scalar/_hidden_model.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Hidden state-space model implementation."""

from probdiffeq.backend import functools
from probdiffeq.backend import numpy as np
from probdiffeq.impl import _hidden_model
Expand Down
1 change: 1 addition & 0 deletions probdiffeq/impl/scalar/_linearise.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Linearisation."""

from probdiffeq.impl import _linearise


Expand Down
1 change: 1 addition & 0 deletions probdiffeq/impl/scalar/_ssm_util.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""SSM utilities."""

from probdiffeq.backend import numpy as np
from probdiffeq.impl import _ssm_util
from probdiffeq.impl.scalar import _normal
Expand Down
1 change: 1 addition & 0 deletions probdiffeq/impl/scalar/_stats.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Random variable implementation."""

from probdiffeq.backend import functools, linalg
from probdiffeq.backend import numpy as np
from probdiffeq.impl import _stats
Expand Down
1 change: 1 addition & 0 deletions probdiffeq/impl/scalar/_transform.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Random variable transformations."""

from probdiffeq.backend import numpy as np
from probdiffeq.impl import _transform
from probdiffeq.impl.scalar import _normal
Expand Down
1 change: 1 addition & 0 deletions probdiffeq/impl/scalar/factorised_impl.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Scalar factorisation."""

from probdiffeq.impl import _impl
from probdiffeq.impl.scalar import (
_conditional,
Expand Down
1 change: 0 additions & 1 deletion probdiffeq/solvers/_solver.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""IVP-solver API."""


from probdiffeq import _interp
from probdiffeq.backend import abc
from probdiffeq.backend import numpy as np
Expand Down
1 change: 1 addition & 0 deletions probdiffeq/solvers/calibrated.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Calibrated IVP solvers."""

from probdiffeq import _interp
from probdiffeq.backend import abc, tree_util
from probdiffeq.impl import impl
Expand Down
1 change: 0 additions & 1 deletion probdiffeq/solvers/strategies/components/cubature.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Cubature rules."""


from probdiffeq.backend import containers, special, tree_util
from probdiffeq.backend import numpy as np
from probdiffeq.backend.typing import Array
Expand Down
1 change: 0 additions & 1 deletion probdiffeq/solvers/strategies/components/priors.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Prior models."""


from probdiffeq.backend import functools
from probdiffeq.backend import numpy as np
from probdiffeq.impl import impl
Expand Down
1 change: 0 additions & 1 deletion probdiffeq/taylor/autodiff.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
r"""Taylor-expand the solution of an initial value problem (IVP)."""


from probdiffeq.backend import control_flow, functools, itertools, tree_util
from probdiffeq.backend import numpy as np
from probdiffeq.backend.typing import Array, Callable
Expand Down
1 change: 0 additions & 1 deletion probdiffeq/taylor/estim.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
r"""Taylor-expand the solution of an initial value problem (IVP)."""


from probdiffeq.backend import functools, ode
from probdiffeq.backend import numpy as np
from probdiffeq.impl import impl
Expand Down
1 change: 0 additions & 1 deletion probdiffeq/timestep.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Time-stepping utilities."""


from probdiffeq.backend import linalg
from probdiffeq.backend import numpy as np

Expand Down
1 change: 1 addition & 0 deletions probdiffeq/util/cond_util.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Conditional-utilities."""

from probdiffeq.backend import containers
from probdiffeq.backend.typing import Any, Array

Expand Down
29 changes: 16 additions & 13 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,12 @@ exclude_also = [

[tool.ruff]
include = ["**.py", "**/pyproject.toml", "**.ipynb"]
# Same as Black.
line-length = 88
indent-width = 4

# See: https://beta.ruff.rs/docs/rules/
[tool.ruff.lint]
select = [
# pycodestyle (warning, error)
"W",
Expand Down Expand Up @@ -151,26 +156,24 @@ ignore = [
# Magic methods don't need a docstring:
"D105",
]
# Same as Black.
line-length = 88
indent-width = 4

[tool.ruff.format]
# Use `\n` line endings for all files
line-ending = "lf"
# Prefer single quotes over double quotes.
quote-style = "double"
skip-magic-trailing-comma = true

[tool.ruff.isort]
[tool.ruff.lint.isort]
split-on-trailing-comma = false

[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]
# Auxiliary functions and tests don't need docstring-enforcement:
"probdiffeq/util/*" = ["D102", "D103"]
"probdiffeq/impl/*" = ["D102"]
"probdiffeq/backend/*" = ["D103"]
"tests/*" = ["D103"]

[tool.ruff.pydocstyle]
[tool.ruff.lint.pydocstyle]
convention = "numpy"


[tool.ruff.format]
# Use `\n` line endings for all files
line-ending = "lf"
# Prefer single quotes over double quotes.
quote-style = "double"
skip-magic-trailing-comma = true
1 change: 1 addition & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests."""

import os

from tests.setup import setup
Expand Down
1 change: 0 additions & 1 deletion tests/setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Test-setup."""


from probdiffeq.backend import config, ode, warnings
from probdiffeq.backend import numpy as np
from probdiffeq.impl import impl
Expand Down
Loading

0 comments on commit 370ea81

Please sign in to comment.