Skip to content

Bumping numpy and jax versions. #865

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 16 commits into from
Closed
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
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ default_language_version:
python: python3
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
rev: v5.0.0
hooks:
- id: check-added-large-files
# Default is 500 which is too strict on the notebooks.
Expand All @@ -31,7 +31,7 @@ repos:
# exclude autogenerated files
exclude: /README\.rst$|\.pot?$
- repo: https://github.com/psf/black
rev: 22.3.0 # Make sure to use the same tag/version as specified in formatting-requirements.txt
rev: 25.1.0 # Make sure to use the same tag/version as specified in formatting-requirements.txt
hooks:
- id: black
language_version: python3
Expand All @@ -40,7 +40,7 @@ repos:
hooks:
- id: isort
- repo: https://github.com/myint/docformatter
rev: v1.3.1
rev: v1.7.7
hooks:
- id: docformatter
args: ['--in-place',
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
.asv/
probnum/
probnum/
1 change: 1 addition & 0 deletions benchmarks/filtsmooth.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Benchmarks for Gaussian filtering."""

import functools

import numpy as np
Expand Down
1 change: 1 addition & 0 deletions benchmarks/ivpsolvers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Benchmarks for probabilistic IVP solvers."""

import numpy as np

from probnum.diffeq import probsolve_ivp
Expand Down
1 change: 1 addition & 0 deletions benchmarks/linearsolvers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Benchmarks for linear solvers."""

import numpy as np

from probnum import linops, problems, randvars
Expand Down
1 change: 1 addition & 0 deletions benchmarks/randprocs.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Benchmarks for random processes."""

import numpy as np
import scipy.stats

Expand Down
2 changes: 1 addition & 1 deletion docs/notebook-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Jupyter notebooks
ipython>=8.9.0<8.11.0
ipython>=8.9.0,<8.11.0
jupyter

# Notebook conversion
Expand Down
4 changes: 2 additions & 2 deletions docs/source/development/adding_to_the_api_documentation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ detail its functionality. This package uses the `NumPy docstring
format <https://numpydoc.readthedocs.io/en/latest/format.html#numpydoc-docstring-guide%3E>`__.
As a rule, all functions which are exposed to the user *must* have
appropriate docstrings. Below is an example of a docstring for a
probabilistic numerical method
probabilistic numerical method
named ``problinsolve`` defined in ``_problinsolve.py`` in the ``linalg`` subpackage.

.. literalinclude:: ../../../src/probnum/linalg/_problinsolve.py
Expand Down Expand Up @@ -103,7 +103,7 @@ documentation. You can configure Sphinx itself or its extensions in the
.. code:: ipython3

from IPython.display import Image

display(Image(filename="../assets/img/developer_guides/sphinx_logo.png", embed=True))


Expand Down
10 changes: 5 additions & 5 deletions docs/source/development/creating_an_example_notebook.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ follow the instructions below.
.. code:: ipython3

from IPython.display import Image
display(Image(url='https://upload.wikimedia.org/wikipedia/commons/thumb/3/38/Jupyter_logo.svg/1200px-Jupyter_logo.svg.png',

display(Image(url='https://upload.wikimedia.org/wikipedia/commons/thumb/3/38/Jupyter_logo.svg/1200px-Jupyter_logo.svg.png',
width=250, embed=True))


Expand Down Expand Up @@ -44,12 +44,12 @@ of the notebook should contain the following code snippet.
# Make inline plots vector graphics instead of raster graphics
%matplotlib inline
from IPython.display import set_matplotlib_formats

set_matplotlib_formats("pdf", "svg")

# Plotting
import matplotlib.pyplot as plt

plt.style.use("../probnum.mplstyle")

This snippet defines the style of plots generated by Matplotlib. For
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@
"# %load -s function_evaluation quadopt_example/observation_operators\n",
"def function_evaluation(\n",
" fun: Callable[[FloatLike], FloatLike], action: FloatLike\n",
") -> np.float_:\n",
") -> np.float64:\n",
" \"\"\"Observe a (noisy) function evaluation of the quadratic objective.\n",
"\n",
" Parameters\n",
Expand Down
2 changes: 1 addition & 1 deletion docs/source/development/quadopt_example/_probsolve_qp.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def probsolve_qp(


def _choose_prior(
fun_params0: Union[randvars.RandomVariable, np.ndarray, None]
fun_params0: Union[randvars.RandomVariable, np.ndarray, None],
) -> randvars.RandomVariable:
"""Initialize the prior distribution over the parameters.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

def function_evaluation(
fun: Callable[[FloatLike], FloatLike], action: FloatLike
) -> np.float_:
) -> np.float64:
"""Observe a (noisy) function evaluation of the quadratic objective.

Parameters
Expand Down
6 changes: 3 additions & 3 deletions docs/source/development/unit_testing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ check out the following guides:
.. code:: ipython3

from IPython.display import Image

display(Image(url='https://code.visualstudio.com/assets/docs/python/testing/test-results.png', embed=True))


Expand All @@ -86,7 +86,7 @@ test. Here is a simple example.

def add(x, y):
return x + y

def test_symmetric():
assert add(3, 5) == add(5, 3)

Expand All @@ -96,7 +96,7 @@ You can do so by parametrizing tests via a decorator.
.. code:: ipython3

import pytest

@pytest.mark.parametrize("x,y", [(3, 5), (-1, 1), (0, 1.2)])
def test_symmetric(x, y):
assert add(x, y) == add(y, x)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@
" return np.roll(v, 1)\n",
"\n",
"n = 5\n",
"P_op = LambdaLinearOperator(shape=(n, n), dtype=np.float_, matmul=mv)\n",
"P_op = LambdaLinearOperator(shape=(n, n), dtype=np.float64, matmul=mv)\n",
"x = np.arange(0., n, 1)\n",
"\n",
"P_op"
Expand Down Expand Up @@ -512,7 +512,7 @@
"def mv(v):\n",
" return v[:n-1]\n",
"\n",
"Pr = LambdaLinearOperator(shape=(n-1, n), dtype=np.float_, matmul=mv)\n",
"Pr = LambdaLinearOperator(shape=(n-1, n), dtype=np.float64, matmul=mv)\n",
"\n",
"# Apply the operator to the 3D normal random variable\n",
"rv_projected = Pr @ rv"
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# `pyproject.toml`, once optional dependencies defined there can reference one another
extras_require = dict()
extras_require["jax"] = [
"jax[cpu]<0.4.20; platform_system!='Windows'",
"jax[cpu]>=0.4.26; platform_system!='Windows'",
]
extras_require["zoo"] = [
"tqdm>=4.0",
Expand Down
2 changes: 1 addition & 1 deletion src/probnum/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
_version.py
_version.py
3 changes: 2 additions & 1 deletion src/probnum/_config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""ProbNum library configuration"""
"""ProbNum library configuration."""

import contextlib
import dataclasses
Expand Down Expand Up @@ -165,6 +165,7 @@ def register(self, key: str, default_value: Any, description: str) -> None:
),
]


# ... and register the default configuration options.
def _register_defaults():
for key, default_value, descr in _DEFAULT_CONFIG_OPTIONS:
Expand Down
2 changes: 1 addition & 1 deletion src/probnum/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
@pytest.fixture(autouse=True)
def autoimport_packages(doctest_namespace): # pylint: disable=missing-any-param-doc
"""This fixture 'imports' standard packages automatically in order to avoid
boilerplate code in doctests"""
boilerplate code in doctests."""

doctest_namespace["pn"] = pn
doctest_namespace["np"] = np
4 changes: 2 additions & 2 deletions src/probnum/diffeq/_odesolution.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

This object is returned by ODESolver.solve().

Provides dense output (by being callable), is sliceable,
and collects the time-grid as well as the discrete-time solution.
Provides dense output (by being callable), is sliceable, and collects the time-grid as
well as the discrete-time solution.
"""

from typing import Optional
Expand Down
1 change: 0 additions & 1 deletion src/probnum/diffeq/_probsolve_ivp.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,6 @@ def probsolve_ivp(
[0.97]
[0.98]
[0.99]]

"""

# Create IVP object
Expand Down
2 changes: 0 additions & 2 deletions src/probnum/diffeq/odefilter/_odefilter.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ class ODEFilter(_odesolver.ODESolver):
.. [2] Bosch, N., and Hennig, P., and Tronarp, F..
Calibrated adaptive probabilistic ODE solvers.
2021.

"""

def __init__(
Expand Down Expand Up @@ -196,7 +195,6 @@ def attempt_step(self, state, dt):
5. With the results of either 4.1. or 4.2. (which both return a predicted RV and
a measured RV), we finally compute the Kalman update and return the result.
Recall that the error estimate has been computed in the third step.

"""

# Read off system matrices; required for calibration / error estimation
Expand Down
1 change: 1 addition & 0 deletions src/probnum/diffeq/odefilter/approx_strategies/_ek.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

Make an intractable information operator tractable with local linearization.
"""

from typing import Optional

import numpy as np
Expand Down
10 changes: 5 additions & 5 deletions src/probnum/diffeq/odefilter/init_routines/_autodiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
# pylint: disable="import-outside-toplevel"
try:
import jax
from jax.config import config
from jax import config
from jax.experimental.jet import jet
import jax.numpy as jnp

config.update("jax_enable_x64", True)

JAX_IS_AVAILABLE = True
except ImportError as JAX_IMPORT_ERROR:
except ImportError:
JAX_IS_AVAILABLE = False
JAX_IMPORT_ERROR_MSG = (
"Cannot perform Jax-based initialization without the optional "
Expand All @@ -31,7 +31,7 @@ class _AutoDiffBase(InitializationRoutine):
def __init__(self):

if not JAX_IS_AVAILABLE:
raise ImportError(JAX_IMPORT_ERROR_MSG) from JAX_IMPORT_ERROR
raise ImportError(JAX_IMPORT_ERROR_MSG)

super().__init__(is_exact=True, requires_jax=True)

Expand Down Expand Up @@ -70,12 +70,12 @@ def _make_autonomous(self, *, ivp):
Turn the ODE into a format that is more convenient to handle with automatic
differentiation. This has no effect on the ODE itself. It is purely internal.
"""
y0_autonomous = jnp.concatenate([ivp.y0, jnp.array([ivp.t0])])
y0_autonomous = jnp.concatenate([ivp.y0, jnp.asarray([ivp.t0])])

def f_autonomous(y):
x, t = y[:-1], y[-1]
fx = ivp.f(t, x)
return jnp.concatenate([fx, jnp.array([1.0])])
return jnp.concatenate([fx, jnp.asarray([1.0])])

return f_autonomous, y0_autonomous

Expand Down
1 change: 0 additions & 1 deletion src/probnum/diffeq/odefilter/init_routines/_interface.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Interface for initialization routines."""


import abc

from probnum import problems, randprocs, randvars
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""Initialization routines based on fitting the prior to (a few steps of a) non-
probabilistc solver."""


from typing import Optional

import numpy as np
Expand Down
1 change: 0 additions & 1 deletion src/probnum/diffeq/odefilter/init_routines/_stack.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Stacking-based initialization routines."""


import numpy as np

from probnum import problems, randprocs, randvars
Expand Down
1 change: 1 addition & 0 deletions src/probnum/diffeq/odefilter/utils/_problem_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

__all__ = ["ivp_to_regression_problem"]


# The ODE information operator is not optional, because in order to create it
# one needs to know the order of the algorithm that is desired
# (i.e. num_prior_derivatives). Since this is a weird input for the function, it seems
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Make a ProbNum ODE solution out of a scipy ODE solution."""

import numpy as np
from scipy.integrate._ivp.common import OdeSolution

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Dense-output can not be used for DOP853, if you use other RK-methods, make sure, that
the current implementation works for them.
"""

import numpy as np
from scipy.integrate._ivp import rk
from scipy.integrate._ivp.common import OdeSolution
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Perturbation functions to perturb the stepsize."""

from typing import Optional, Union

import numpy as np
Expand Down
4 changes: 2 additions & 2 deletions src/probnum/diffeq/stepsize/_propose_firststep.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
def propose_firststep(ivp):
"""Propose a suitable first step-size that can be taken by an ODE solver.

This function implements a lazy version of the algorithm on p. 169
of Hairer, Wanner, Norsett.
This function implements a lazy version of the algorithm on p. 169 of Hairer,
Wanner, Norsett.
"""
norm_y0 = np.linalg.norm(ivp.y0)
norm_dy0 = np.linalg.norm(ivp.f(ivp.t0, ivp.y0))
Expand Down
10 changes: 5 additions & 5 deletions src/probnum/filtsmooth/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
"""Bayesian Filtering and Smoothing.

This package provides different kinds of Bayesian filters and smoothers
which estimate the distribution over observed and hidden variables in a
sequential model. The two operations differ by what information they
use. Filtering considers all observations up to a given point, while
smoothing takes the entire set of observations into account.
This package provides different kinds of Bayesian filters and smoothers which estimate
the distribution over observed and hidden variables in a sequential model. The two
operations differ by what information they use. Filtering considers all observations up
to a given point, while smoothing takes the entire set of observations into account.
"""

from . import gaussian, particle, utils
from ._bayesfiltsmooth import BayesFiltSmooth
from ._kalman_filter_smoother import filter_kalman, smooth_rts
Expand Down
5 changes: 2 additions & 3 deletions src/probnum/filtsmooth/_timeseriesposterior.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@
DenseOutputValueType = Union[randvars.RandomVariable, randvars._RandomVariableList]
"""Output type of interpolation.

Dense evaluation of a TimeSeriesPosterior returns a RandomVariable
if evaluated at a single location,
and a _RandomVariableList if evaluated at an array of locations.
Dense evaluation of a TimeSeriesPosterior returns a RandomVariable if evaluated at a
single location, and a _RandomVariableList if evaluated at an array of locations.
"""


Expand Down
1 change: 0 additions & 1 deletion src/probnum/filtsmooth/gaussian/_kalman.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Gaussian filtering and smoothing."""


from typing import Iterable, Optional, Union

import numpy as np
Expand Down
Loading