cuthbert 0.1.1__tar.gz → 0.1.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {cuthbert-0.1.1 → cuthbert-0.1.3}/PKG-INFO +1 -1
- cuthbert-0.1.3/README.md +131 -0
- {cuthbert-0.1.1 → cuthbert-0.1.3}/cuthbert/gaussian/taylor/associative_filter.py +2 -1
- {cuthbert-0.1.1 → cuthbert-0.1.3}/cuthbert/gaussian/taylor/filter.py +3 -2
- {cuthbert-0.1.1 → cuthbert-0.1.3}/cuthbert/gaussian/taylor/non_associative_filter.py +73 -23
- cuthbert-0.1.3/hatch_build.py +35 -0
- {cuthbert-0.1.1 → cuthbert-0.1.3}/pyproject.toml +4 -6
- cuthbert-0.1.1/README.md +0 -1
- {cuthbert-0.1.1 → cuthbert-0.1.3}/.gitignore +0 -0
- {cuthbert-0.1.1 → cuthbert-0.1.3}/cuthbert/README.md +0 -0
- {cuthbert-0.1.1 → cuthbert-0.1.3}/cuthbert/__init__.py +0 -0
- {cuthbert-0.1.1 → cuthbert-0.1.3}/cuthbert/discrete/README.md +0 -0
- {cuthbert-0.1.1 → cuthbert-0.1.3}/cuthbert/discrete/__init__.py +0 -0
- {cuthbert-0.1.1 → cuthbert-0.1.3}/cuthbert/discrete/filter.py +0 -0
- {cuthbert-0.1.1 → cuthbert-0.1.3}/cuthbert/discrete/smoother.py +0 -0
- {cuthbert-0.1.1 → cuthbert-0.1.3}/cuthbert/discrete/types.py +0 -0
- {cuthbert-0.1.1 → cuthbert-0.1.3}/cuthbert/ensemble_kalman/README.md +0 -0
- {cuthbert-0.1.1 → cuthbert-0.1.3}/cuthbert/ensemble_kalman/__init__.py +0 -0
- {cuthbert-0.1.1 → cuthbert-0.1.3}/cuthbert/ensemble_kalman/ensemble_kalman_filter.py +0 -0
- {cuthbert-0.1.1 → cuthbert-0.1.3}/cuthbert/ensemble_kalman/ensemble_rts_smoother.py +0 -0
- {cuthbert-0.1.1 → cuthbert-0.1.3}/cuthbert/ensemble_kalman/types.py +0 -0
- {cuthbert-0.1.1 → cuthbert-0.1.3}/cuthbert/factorial/README.md +0 -0
- {cuthbert-0.1.1 → cuthbert-0.1.3}/cuthbert/factorial/__init__.py +0 -0
- {cuthbert-0.1.1 → cuthbert-0.1.3}/cuthbert/factorial/discrete.py +0 -0
- {cuthbert-0.1.1 → cuthbert-0.1.3}/cuthbert/factorial/filtering.py +0 -0
- {cuthbert-0.1.1 → cuthbert-0.1.3}/cuthbert/factorial/gaussian.py +0 -0
- {cuthbert-0.1.1 → cuthbert-0.1.3}/cuthbert/factorial/smc.py +0 -0
- {cuthbert-0.1.1 → cuthbert-0.1.3}/cuthbert/factorial/types.py +0 -0
- {cuthbert-0.1.1 → cuthbert-0.1.3}/cuthbert/factorial/utils.py +0 -0
- {cuthbert-0.1.1 → cuthbert-0.1.3}/cuthbert/filtering.py +0 -0
- {cuthbert-0.1.1 → cuthbert-0.1.3}/cuthbert/gaussian/README.md +0 -0
- {cuthbert-0.1.1 → cuthbert-0.1.3}/cuthbert/gaussian/__init__.py +0 -0
- {cuthbert-0.1.1 → cuthbert-0.1.3}/cuthbert/gaussian/kalman.py +0 -0
- {cuthbert-0.1.1 → cuthbert-0.1.3}/cuthbert/gaussian/moments/__init__.py +0 -0
- {cuthbert-0.1.1 → cuthbert-0.1.3}/cuthbert/gaussian/moments/associative_filter.py +0 -0
- {cuthbert-0.1.1 → cuthbert-0.1.3}/cuthbert/gaussian/moments/filter.py +0 -0
- {cuthbert-0.1.1 → cuthbert-0.1.3}/cuthbert/gaussian/moments/non_associative_filter.py +0 -0
- {cuthbert-0.1.1 → cuthbert-0.1.3}/cuthbert/gaussian/moments/smoother.py +0 -0
- {cuthbert-0.1.1 → cuthbert-0.1.3}/cuthbert/gaussian/moments/types.py +0 -0
- {cuthbert-0.1.1 → cuthbert-0.1.3}/cuthbert/gaussian/taylor/__init__.py +0 -0
- {cuthbert-0.1.1 → cuthbert-0.1.3}/cuthbert/gaussian/taylor/smoother.py +0 -0
- {cuthbert-0.1.1 → cuthbert-0.1.3}/cuthbert/gaussian/taylor/types.py +0 -0
- {cuthbert-0.1.1 → cuthbert-0.1.3}/cuthbert/gaussian/types.py +0 -0
- {cuthbert-0.1.1 → cuthbert-0.1.3}/cuthbert/gaussian/utils.py +0 -0
- {cuthbert-0.1.1 → cuthbert-0.1.3}/cuthbert/inference.py +0 -0
- {cuthbert-0.1.1 → cuthbert-0.1.3}/cuthbert/smc/README.md +0 -0
- {cuthbert-0.1.1 → cuthbert-0.1.3}/cuthbert/smc/__init__.py +0 -0
- {cuthbert-0.1.1 → cuthbert-0.1.3}/cuthbert/smc/backward_sampler.py +0 -0
- {cuthbert-0.1.1 → cuthbert-0.1.3}/cuthbert/smc/marginal_particle_filter.py +0 -0
- {cuthbert-0.1.1 → cuthbert-0.1.3}/cuthbert/smc/particle_filter.py +0 -0
- {cuthbert-0.1.1 → cuthbert-0.1.3}/cuthbert/smc/types.py +0 -0
- {cuthbert-0.1.1 → cuthbert-0.1.3}/cuthbert/smoothing.py +0 -0
- {cuthbert-0.1.1 → cuthbert-0.1.3}/cuthbert/utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: cuthbert
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.3
|
|
4
4
|
Summary: State-space model inference with JAX
|
|
5
5
|
Author-email: Sam Duffield <s@mduffield.com>, Sahel Iqbal <sahel13miqbal@proton.me>, Adrien Corenflos <adrien.corenflos.stats@gmail.com>
|
|
6
6
|
License: Apache-2.0
|
cuthbert-0.1.3/README.md
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
<!-- --8<-- [start:intro] -->
|
|
2
|
+
<div align="center">
|
|
3
|
+
<img src="https://raw.githubusercontent.com/state-space-models/cuthbert/main/docs/assets/cuthbert.png" alt="cuthbert logo"></img>
|
|
4
|
+
</div>
|
|
5
|
+
|
|
6
|
+
A JAX library for state-space model inference
|
|
7
|
+
(filtering, smoothing, static parameter estimation).
|
|
8
|
+
|
|
9
|
+
> Disclaimer: The name `cuthbert` was chosen as a playful nod to the well-known
|
|
10
|
+
> caterpillar cake rivalry between Aldi and M&S in the UK, as the classic state-space
|
|
11
|
+
> model diagram looks vaguely like a caterpillar. However, this software project
|
|
12
|
+
> has no formal connection to Aldi, M&S, or any food products (notwithstanding the coffee drunk during its writeup).
|
|
13
|
+
> `cuthbert` is simply a fun name for this state-space model library and should not be interpreted as an
|
|
14
|
+
> endorsement, association, or affiliation with any brand or animal themed baked goods.
|
|
15
|
+
|
|
16
|
+
[](https://discord.gg/W9BA4Aj7Rx)
|
|
17
|
+
[](https://github.com/state-space-models/cuthbert)
|
|
18
|
+
[](https://pypi.org/project/cuthbert/)
|
|
19
|
+
[](https://state-space-models.github.io/cuthbert/)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
If you want to jump right in, check out our [examples](https://state-space-models.github.io/cuthbert/examples).
|
|
23
|
+
Maybe a [simple Kalman filter for tracking](https://state-space-models.github.io/cuthbert/examples/kalman_tracking)
|
|
24
|
+
or a [factorial state-space model for modelling international football](https://state-space-models.github.io/cuthbert/examples/factorial_football).
|
|
25
|
+
<!-- --8<-- [end:intro] -->
|
|
26
|
+
|
|
27
|
+
<!-- --8<-- [start:goals] -->
|
|
28
|
+
### Goals
|
|
29
|
+
- Simple, flexible and performant interface for state-space model inference.
|
|
30
|
+
- Decoupling of model specification and inference. `cuthbert` is built to swap between
|
|
31
|
+
different **inference** methods without be tied to a specific model specification.
|
|
32
|
+
- Compose with the [JAX ecosystem](#ecosystem) for extensive external tools.
|
|
33
|
+
- Functional API: The only classes in `cuthbert` are `NamedTuple`s and `Protocol`s.
|
|
34
|
+
All functions are pure and work seamlessly with `jax.grad`, `jax.jit`, `jax.vmap` etc.
|
|
35
|
+
- Methods for filtering: $p(x_t \mid y_{1:t}, \theta)$.
|
|
36
|
+
- Methods for smoothing: $p(x_{0:T} \mid y_{1:T}, \theta)$ or $p(x_{t} \mid y_{1:T}, \theta)$.
|
|
37
|
+
- Methods for static parameter estimation: $p(\theta \mid y_{1:T})$
|
|
38
|
+
or $\text{argmax} p(y_{1:T} \mid \theta)$.
|
|
39
|
+
- This includes support for forward-backward/Baum-Welch, particle filtering/sequential Monte Carlo,
|
|
40
|
+
Kalman filtering (+ extended/unscented/ensemble), expectation-maximization and more!
|
|
41
|
+
|
|
42
|
+
### Non-goals
|
|
43
|
+
- Tools for defining models and distributions. `cuthbert` is not a probabilistic programming language (PPL).
|
|
44
|
+
But can easily compose with [`dynamax`](https://github.com/probml/dynamax), [`distrax`](https://github.com/google-deepmind/distrax), [`numpyro`](https://github.com/pyro-ppl/numpyro) and [`pymc`](https://github.com/pymc-devs/pymc) in a similar way to how [`blackjax` does](https://blackjax-devs.github.io/blackjax/).
|
|
45
|
+
- ["SMC Samplers"](https://www.stats.ox.ac.uk/~doucet/delmoral_doucet_jasra_sequentialmontecarlosamplersJRSSB.pdf) which sample from a posterior
|
|
46
|
+
distribution which is not (necessarily) a state-space model - [`blackjax` is great for this](https://github.com/blackjax-devs/blackjax/tree/main/blackjax/smc).
|
|
47
|
+
<!-- --8<-- [end:goals] -->
|
|
48
|
+
|
|
49
|
+
<!-- --8<-- [start:codebase_structure] -->
|
|
50
|
+
### Codebase structure
|
|
51
|
+
|
|
52
|
+
The codebase is structured as follows:
|
|
53
|
+
|
|
54
|
+
- `cuthbert`: The main package with unified interface for filtering and smoothing.
|
|
55
|
+
- `cuthbertlib`: A collection of atomic, smaller-scoped tools useful for state-space model inference,
|
|
56
|
+
that represent the building blocks that power the main `cuthbert` package.
|
|
57
|
+
<!-- --8<-- [end:codebase_structure] -->
|
|
58
|
+
- `docs`: Source code for the documentation for `cuthbert` and `cuthbertlib`.
|
|
59
|
+
- `pkg`: Packaging configuration for publishing `cuthbert` and `cuthbertlib` to PyPI.
|
|
60
|
+
- `tests`: Tests for the `cuthbert` and `cuthbertlib` packages.
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
<!-- --8<-- [start:installation] -->
|
|
64
|
+
## Installation
|
|
65
|
+
|
|
66
|
+
`cuthbert` depends on JAX, so you'll need to [install JAX](https://docs.jax.dev/en/latest/installation.html) for the available hardware (CPU, GPU, or TPU).
|
|
67
|
+
For example, on computers with NVIDIA GPUs:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
pip install -U "jax[cuda13]"
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### From PyPI
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
pip install -U cuthbert
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Installing `cuthbert` will also install `cuthbertlib`.
|
|
80
|
+
You can also install `cuthbertlib` on its own:
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
pip install -U cuthbertlib
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Local development (uv)
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
git clone https://github.com/state-space-models/cuthbert.git
|
|
90
|
+
cd cuthbert
|
|
91
|
+
uv sync --package cuthbert --extra tests
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Local development (pip)
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
git clone https://github.com/state-space-models/cuthbert.git
|
|
98
|
+
cd cuthbert
|
|
99
|
+
pip install -e ./pkg/cuthbertlib
|
|
100
|
+
pip install -e "./pkg/cuthbert[tests]"
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
<!-- --8<-- [end:installation] -->
|
|
104
|
+
|
|
105
|
+
<!-- --8<-- [start:ecosystem] -->
|
|
106
|
+
## Ecosystem
|
|
107
|
+
- `cuthbert` is built on top of [`jax`](https://github.com/google/jax) and composes
|
|
108
|
+
easily with other JAX packages, e.g. [`optax`](https://github.com/google-deepmind/optax)
|
|
109
|
+
for optimization, [`flax`](https://github.com/google/flax) for neural networks, and
|
|
110
|
+
[`blackjax`](https://github.com/blackjax-devs/blackjax) for (SG)MCMC as well as the PPLs
|
|
111
|
+
mentioned [above](#non-goals).
|
|
112
|
+
- What about [`dynamax`](https://github.com/probml/dynamax)?
|
|
113
|
+
- `dynamax` is a great library for state-space model specification and inference with
|
|
114
|
+
discrete or Gaussian state-space models. `cuthbert` is focused on inference
|
|
115
|
+
with arbitrary state-space models via e.g. SMC that is not supported in `dynamax`.
|
|
116
|
+
However as they are both built on [`jax`](https://github.com/google/jax)
|
|
117
|
+
they can be used together! A `dynamax`
|
|
118
|
+
model can be passed to `cuthbert` for inference.
|
|
119
|
+
- And [`particles`](https://github.com/nchopin/particles)?
|
|
120
|
+
- [`particles`](https://github.com/nchopin/particles) and the accompanying book
|
|
121
|
+
[Sequential Monte Carlo Methods in Practice](https://link.springer.com/book/10.1007/978-3-030-47845-2)
|
|
122
|
+
are wonderful learning materials for state-space models and SMC.
|
|
123
|
+
`cuthbert` is more focused on performance and composability with the JAX ecosystem.
|
|
124
|
+
- Much of the code in `cuthbert` is built on work from [`sqrt-parallel-smoothers`](https://github.com/EEA-sensors/sqrt-parallel-smoothers), [`mocat`](https://github.com/SamDuffield/mocat) and [`abile`](https://github.com/SamDuffield/abile).
|
|
125
|
+
<!-- --8<-- [end:ecosystem] -->
|
|
126
|
+
|
|
127
|
+
## Contributing
|
|
128
|
+
|
|
129
|
+
We're always looking for contributions!
|
|
130
|
+
Check out the [contributing guide](CONTRIBUTING.md) for more information.
|
|
131
|
+
|
|
@@ -144,13 +144,14 @@ def filter_prepare(
|
|
|
144
144
|
chol_Q = jnp.where(skip_predict_flag, jnp.zeros_like(chol_Q), chol_Q)
|
|
145
145
|
|
|
146
146
|
observation_output = get_observation_func(dummy_state, model_inputs)
|
|
147
|
-
H, d, chol_R, observation = non_associative_filter.process_observation(
|
|
147
|
+
H, d, chol_R, observation, correction = non_associative_filter.process_observation(
|
|
148
148
|
observation_output,
|
|
149
149
|
rtol=rtol,
|
|
150
150
|
ignore_nan_dims=ignore_nan_dims,
|
|
151
151
|
)
|
|
152
152
|
|
|
153
153
|
elem = filtering.associative_params_single(F, c, chol_Q, H, d, chol_R, observation)
|
|
154
|
+
elem = elem._replace(ell=elem.ell + correction)
|
|
154
155
|
|
|
155
156
|
return LinearizedKalmanFilterState(
|
|
156
157
|
elem=elem,
|
|
@@ -15,10 +15,11 @@ $$
|
|
|
15
15
|
and potentials as
|
|
16
16
|
|
|
17
17
|
$$
|
|
18
|
-
G(x) \approx N(x \mid m, L L^T),
|
|
18
|
+
G(x) \approx \exp(c) N(x \mid m, L L^T),
|
|
19
19
|
$$
|
|
20
20
|
|
|
21
|
-
where $
|
|
21
|
+
where $c$ matches the log potential at the expansion point and contributes to the
|
|
22
|
+
log evidence when $L L^T$ is nonsingular on the active coordinates.
|
|
22
23
|
|
|
23
24
|
See `cuthbertlib.linearize` for more details.
|
|
24
25
|
|
|
@@ -15,6 +15,7 @@ from cuthbert.utils import dummy_tree_like
|
|
|
15
15
|
from cuthbertlib.kalman import filtering
|
|
16
16
|
from cuthbertlib.linalg import block_marginal_sqrt_cov
|
|
17
17
|
from cuthbertlib.linearize import linearize_log_density, linearize_taylor
|
|
18
|
+
from cuthbertlib.stats import multivariate_normal
|
|
18
19
|
from cuthbertlib.types import Array, ArrayLike, ArrayTreeLike, KeyArray, LogDensity
|
|
19
20
|
|
|
20
21
|
|
|
@@ -23,8 +24,29 @@ def process_observation(
|
|
|
23
24
|
| tuple[LogPotential, Array],
|
|
24
25
|
rtol: float | None = None,
|
|
25
26
|
ignore_nan_dims: bool = False,
|
|
26
|
-
) -> tuple[Array, Array, Array, Array]:
|
|
27
|
-
"""
|
|
27
|
+
) -> tuple[Array, Array, Array, Array, Array]:
|
|
28
|
+
r"""Prepare a Gaussian observation for the Taylor Kalman update.
|
|
29
|
+
|
|
30
|
+
Returns a tuple with parameters for a Gaussian pseudo-observation. For
|
|
31
|
+
a `LogPotential` input, an additional correction term $\log G(x_0) - \log q(x_0)$
|
|
32
|
+
is computed, where $G$ is the potential and $q$ is the Gaussian pseudo-potential.
|
|
33
|
+
Adding this correction to the log normalizing constant ensures that constant factors
|
|
34
|
+
to the log normalizing constant are properly accounted for.
|
|
35
|
+
|
|
36
|
+
Args:
|
|
37
|
+
observation_output: Either `(log_conditional_density, point, observation)`
|
|
38
|
+
or `(log_potential, point)` for a unary observation potential.
|
|
39
|
+
rtol: Relative singular-value cutoff for inverting precision matrices
|
|
40
|
+
during linearization.
|
|
41
|
+
ignore_nan_dims: Whether to treat coordinates with NaN on the diagonal
|
|
42
|
+
of the precision matrix as missing.
|
|
43
|
+
|
|
44
|
+
Returns:
|
|
45
|
+
Tuple `(H, d, chol_R, y, correction)` with the observation matrix, offset,
|
|
46
|
+
square-root noise covariance, observation or pseudo-observation, and
|
|
47
|
+
additive log-evidence correction. The correction is zero for conditional
|
|
48
|
+
densities, skipped observations, or singular or non-finite active factors.
|
|
49
|
+
"""
|
|
28
50
|
if len(observation_output) == 3:
|
|
29
51
|
observation_cond_log_density, linearization_point, observation = (
|
|
30
52
|
observation_output
|
|
@@ -36,25 +58,47 @@ def process_observation(
|
|
|
36
58
|
rtol=rtol,
|
|
37
59
|
ignore_nan_dims=ignore_nan_dims,
|
|
38
60
|
)
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
)
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
61
|
+
return H, d, chol_R, observation, jnp.zeros((), dtype=d.dtype)
|
|
62
|
+
|
|
63
|
+
observation_log_potential, linearization_point = observation_output
|
|
64
|
+
skip = jnp.isnan(linearization_point).all()
|
|
65
|
+
anchor = jnp.where(skip, 0.0, linearization_point)
|
|
66
|
+
|
|
67
|
+
def log_potential_with_value(x: ArrayLike) -> tuple[Array, Array]:
|
|
68
|
+
value = observation_log_potential(x)
|
|
69
|
+
return value, value
|
|
70
|
+
|
|
71
|
+
d, chol_R, value = linearize_taylor(
|
|
72
|
+
log_potential_with_value,
|
|
73
|
+
anchor,
|
|
74
|
+
has_aux=True,
|
|
75
|
+
rtol=rtol,
|
|
76
|
+
ignore_nan_dims=ignore_nan_dims,
|
|
77
|
+
)
|
|
78
|
+
# With H = -I and y = 0, the pseudo-observation residual is x - d.
|
|
79
|
+
H = -jnp.eye(d.shape[0])
|
|
80
|
+
missing = skip | (ignore_nan_dims & jnp.isnan(jnp.diag(chol_R)))
|
|
81
|
+
observation = jnp.where(missing, jnp.nan, 0.0)
|
|
82
|
+
|
|
83
|
+
# The active block of the Taylor factor is already lower triangular.
|
|
84
|
+
active_factor = jnp.where(missing[:, None] | missing[None, :], 0.0, chol_R)
|
|
85
|
+
apply_correction = (
|
|
86
|
+
~skip
|
|
87
|
+
& jnp.isfinite(active_factor).all()
|
|
88
|
+
& jnp.all(missing | (jnp.diag(active_factor) != 0))
|
|
89
|
+
)
|
|
90
|
+
# A padded coordinate has log density zero at residual zero.
|
|
91
|
+
ignored = missing | ~apply_correction
|
|
92
|
+
padding_scale = jnp.asarray((2 * jnp.pi) ** -0.5, dtype=chol_R.dtype)
|
|
93
|
+
factor = jnp.where(apply_correction, active_factor, 0.0) + jnp.diag(
|
|
94
|
+
jnp.where(ignored, padding_scale, 0.0)
|
|
95
|
+
)
|
|
96
|
+
residual = jnp.where(ignored, 0.0, anchor - d)
|
|
97
|
+
gaussian_value = multivariate_normal.logpdf(
|
|
98
|
+
residual, jnp.zeros_like(residual), factor, nan_support=False
|
|
99
|
+
)
|
|
100
|
+
correction = jnp.where(apply_correction, value - gaussian_value, 0.0)
|
|
101
|
+
return H, d, chol_R, observation, correction
|
|
58
102
|
|
|
59
103
|
|
|
60
104
|
def init_prepare(
|
|
@@ -222,14 +266,20 @@ def filter_combine(
|
|
|
222
266
|
|
|
223
267
|
observation_output = get_observation_func(predict_state, state_2.model_inputs)
|
|
224
268
|
|
|
225
|
-
H, d, chol_R, observation = process_observation(
|
|
269
|
+
H, d, chol_R, observation, correction = process_observation(
|
|
226
270
|
observation_output,
|
|
227
271
|
rtol=rtol,
|
|
228
272
|
ignore_nan_dims=ignore_nan_dims,
|
|
229
273
|
)
|
|
230
274
|
|
|
231
275
|
(update_mean, update_chol_cov), log_normalizing_constant = filtering.update(
|
|
232
|
-
predict_mean,
|
|
276
|
+
predict_mean,
|
|
277
|
+
predict_chol_cov,
|
|
278
|
+
H,
|
|
279
|
+
d,
|
|
280
|
+
chol_R,
|
|
281
|
+
observation,
|
|
282
|
+
log_normalizing_constant=correction,
|
|
233
283
|
)
|
|
234
284
|
|
|
235
285
|
return linearized_kalman_filter_state_dummy_elem(
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"""Hatch build hook that packages the top-level `cuthbert` source dir."""
|
|
2
|
+
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
from hatchling.builders.hooks.plugin.interface import BuildHookInterface
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class CustomBuildHook(BuildHookInterface):
|
|
9
|
+
"""Include the source package in wheels and resolve the README symlink in sdists."""
|
|
10
|
+
|
|
11
|
+
def initialize(self, version, build_data):
|
|
12
|
+
"""Adjust the files of the artifact being built."""
|
|
13
|
+
force_include = build_data["force_include"]
|
|
14
|
+
if self.target_name == "sdist":
|
|
15
|
+
# An sdist stores symlinks as links, and the README link points
|
|
16
|
+
# outside the archive, so ship the file it points at instead.
|
|
17
|
+
for source in [s for s in force_include if Path(s).is_symlink()]:
|
|
18
|
+
target = Path(source).resolve()
|
|
19
|
+
if not target.exists():
|
|
20
|
+
raise RuntimeError(f"Symlink {source} points at missing {target}")
|
|
21
|
+
force_include[str(target)] = force_include.pop(source)
|
|
22
|
+
return
|
|
23
|
+
# Editable installs reach the source through a .pth file (dev-mode-dirs);
|
|
24
|
+
# a copy in site-packages would shadow the working tree.
|
|
25
|
+
if self.target_name != "wheel" or version == "editable":
|
|
26
|
+
return
|
|
27
|
+
# A wheel built from the sdist: the sdist already holds the package.
|
|
28
|
+
if Path(self.root, "PKG-INFO").is_file():
|
|
29
|
+
return
|
|
30
|
+
# A wheel built from the workspace: the source sits two levels up.
|
|
31
|
+
name = self.metadata.name
|
|
32
|
+
source = Path(self.root, "..", "..", name)
|
|
33
|
+
if not source.is_dir():
|
|
34
|
+
raise RuntimeError(f"Cannot find the {name} source dir at {source}")
|
|
35
|
+
force_include[str(source)] = name
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
[build-system]
|
|
2
|
-
requires = ["hatchling"]
|
|
2
|
+
requires = ["hatchling>=1.19"]
|
|
3
3
|
build-backend = "hatchling.build"
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "cuthbert"
|
|
7
|
-
version = "0.1.
|
|
7
|
+
version = "0.1.3"
|
|
8
8
|
description = "State-space model inference with JAX"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.10"
|
|
@@ -37,12 +37,10 @@ cuthbertlib = { workspace = true }
|
|
|
37
37
|
[tool.hatch.build]
|
|
38
38
|
dev-mode-dirs = ["../.."]
|
|
39
39
|
|
|
40
|
+
[tool.hatch.build.hooks.custom]
|
|
41
|
+
|
|
40
42
|
[tool.hatch.build.targets.wheel]
|
|
41
43
|
packages = ["cuthbert"]
|
|
42
44
|
|
|
43
|
-
[tool.hatch.build.targets.wheel.force-include]
|
|
44
|
-
"../../cuthbert" = "cuthbert"
|
|
45
|
-
|
|
46
45
|
[tool.hatch.build.targets.sdist.force-include]
|
|
47
46
|
"../../cuthbert" = "cuthbert"
|
|
48
|
-
"../../README.md" = "README.md"
|
cuthbert-0.1.1/README.md
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
../../README.md
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|