diff --git a/docs/examples_solver_config/conditioning-on-zero-residual.py b/docs/examples_solver_config/conditioning-on-zero-residual.py index abf78fbf..ecc9b67d 100644 --- a/docs/examples_solver_config/conditioning-on-zero-residual.py +++ b/docs/examples_solver_config/conditioning-on-zero-residual.py @@ -132,11 +132,6 @@ def vector_field(y, t): # noqa: ARG001 } -def log_residual(*args): - """Evaluate the log-ODE-residual.""" - return jnp.log10(jnp.abs(residual(*args))) - - def residual(x, t): """Evaluate the ODE residual.""" return x[1] - jax.vmap(jax.vmap(vector_field), in_axes=(0, None))(x[0], t) diff --git a/makefile b/makefile index f8573a6e..c3a5caeb 100644 --- a/makefile +++ b/makefile @@ -47,3 +47,6 @@ doc: make example make benchmarks-plot-results JUPYTER_PLATFORM_DIRS=1 mkdocs build + +find-dead-code: + vulture . --ignore-names case*,fixture*,*jvp --exclude probdiffeq/_version.py diff --git a/probdiffeq/backend/numpy.py b/probdiffeq/backend/numpy.py index 47216e5d..bbf65098 100644 --- a/probdiffeq/backend/numpy.py +++ b/probdiffeq/backend/numpy.py @@ -44,10 +44,6 @@ def diff(arr, /): return jnp.diff(arr) -def diff_along_axis(arr, /, *, axis): - return jnp.diff(arr, axis=axis) - - def reshape(arr, /, new_shape, order="C"): return jnp.reshape(arr, new_shape, order=order) diff --git a/probdiffeq/backend/ode.py b/probdiffeq/backend/ode.py index 2436ec64..1097f080 100644 --- a/probdiffeq/backend/ode.py +++ b/probdiffeq/backend/ode.py @@ -49,23 +49,6 @@ def solution(t): return solution -def ivp_logistic(): - # Local imports because diffeqzoo is not an official dependency - from diffeqzoo import backend, ivps - - if not backend.has_been_selected: - backend.select("jax") - - f, u0, (t0, _), f_args = ivps.logistic() - t1 = 0.75 - - @jax.jit - def vf(x, *, t): # noqa: ARG001 - return f(x, *f_args) - - return vf, (u0,), (t0, t1) - - def ivp_lotka_volterra(): # Local imports because diffeqzoo is not an official dependency from diffeqzoo import backend, ivps @@ -83,34 +66,6 @@ def vf(x, *, t): # noqa: ARG001 return vf, (u0,), (t0, t1) -def ivp_affine_multi_dimensional(): - t0, t1 = 0.0, 2.0 - u0 = jnp.ones((2,)) - - @jax.jit - def vf(x, *, t): # noqa: ARG001 - return 2 * x - - def solution(t): - return jnp.exp(2 * t) * jnp.ones((2,)) - - return vf, (u0,), (t0, t1), solution - - -def ivp_affine_scalar(): - t0, t1 = 0.0, 2.0 - u0 = 1.0 - - @jax.jit - def vf(x, *, t): # noqa: ARG001 - return 2 * x - - def solution(t): - return jnp.exp(2 * t) - - return vf, (u0,), (t0, t1), solution - - def ivp_three_body_1st(): # Local imports because diffeqzoo is not an official dependency from diffeqzoo import backend, ivps diff --git a/probdiffeq/util/filter_util.py b/probdiffeq/util/filter_util.py index f396dbc7..fb0218cd 100644 --- a/probdiffeq/util/filter_util.py +++ b/probdiffeq/util/filter_util.py @@ -7,8 +7,6 @@ from probdiffeq.backend.typing import Any -# TODO: fixedpointsmoother and kalmanfilter should be estimate() -# with two different methods. This saves a lot of code. def estimate_fwd(data, /, init, prior_transitions, observation_model, *, estimator): """Estimate forward-in-time.""" initialise, step = estimator @@ -91,7 +89,7 @@ def _initialise(rv, data, model) -> _KFState: observed, conditional = ssm.conditional.revert(rv, model) corrected = ssm.conditional.apply(data, conditional) logpdf = ssm.stats.logpdf(data, observed) - return _KFState(corrected, 1.0, logpdf) + return _KFState(corrected, num_data_points=0.0, logpdf=logpdf) def _step(state: _KFState, cond_and_data_and_obs) -> tuple[_KFState, _KFState]: conditional, data, observation = cond_and_data_and_obs @@ -105,7 +103,7 @@ def _step(state: _KFState, cond_and_data_and_obs) -> tuple[_KFState, _KFState]: # Update logpdf logpdf_new = ssm.stats.logpdf(data, observed) logpdf_mean = (logpdf * num_data + logpdf_new) / (num_data + 1) - state = _KFState(corrected, num_data + 1.0, logpdf_mean) + state = _KFState(corrected, num_data_points=num_data + 1.0, logpdf=logpdf_mean) # Scan-compatible output return state, state