Skip to content

Commit 5f6084d

Browse files
authored
Update to cuthbert v0.0.14 (#300)
Cuthbert cut a new release which had some breaking changes (in particular, filters no longer call init_prepare themselves, that's now our jobs). There was also a changing in the filenaming for EnKF (mia culpa). This pins an exact version, since I think cuthbert is still undergoing breaking changes every now and then.
1 parent 509fbcd commit 5f6084d

2 files changed

Lines changed: 15 additions & 5 deletions

File tree

dynestyx/inference/integrations/cuthbert/discrete_filter.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import jax.numpy as jnp
66
import numpyro.distributions as dist
77
from cuthbert import filter as cuthbert_filter
8-
from cuthbert.enkf import ensemble_kalman_filter
8+
from cuthbert.ensemble_kalman import ensemble_kalman_filter
99
from cuthbert.gaussian import kalman, taylor
1010
from cuthbert.smc import particle_filter
1111
from cuthbertlib.resampling import (
@@ -250,11 +250,21 @@ def compute_cuthbert_filter(
250250
f"filter is not associative: {type(filter_config).__name__}."
251251
)
252252

253+
init_inputs = jax.tree.map(lambda leaf: leaf[0], cuthbert_inputs)
254+
filter_inputs = jax.tree.map(lambda leaf: leaf[1:], cuthbert_inputs)
255+
if key is None:
256+
init_state = filter_obj.init_prepare(init_inputs)
257+
filter_key = None
258+
else:
259+
init_key, filter_key = jax.random.split(key)
260+
init_state = filter_obj.init_prepare(init_inputs, key=init_key)
261+
253262
raw_states = cuthbert_filter(
254263
filter_obj,
255-
cuthbert_inputs,
264+
filter_inputs,
265+
init_state,
256266
parallel=cast(bool, parallel),
257-
key=key,
267+
key=filter_key,
258268
)
259269
marginal_loglik = raw_states.log_normalizing_constant[-1]
260270
states = (

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ classifiers = [
3131
]
3232
dependencies = [
3333
"effectful>=0.4.0",
34-
"cuthbert>=0.0.10",
35-
"cuthbertlib>=0.0.10",
34+
"cuthbert==0.0.14",
35+
"cuthbertlib==0.0.14",
3636
"cd-dynamax>=0.3.3",
3737
"matplotlib>=3.10.7",
3838
"numpyro>=0.19.0",

0 commit comments

Comments
 (0)