State¶
mgsl.SLState
dataclass
¶
State of a set of localisation paths at one observation time.
It holds everything needed to continue the paths: :func:mgsl.advance continues them and
:func:mgsl.finalize draws samples from them. Random numbers are derived from the run's
key, the path index and the global step, so a run split into several :func:mgsl.advance
calls gives the samples of one uninterrupted run over the same grid points with the same
options (bit for bit with the same batch_size, devices and vectorize; to
rounding otherwise).
Attributes:
| Name | Type | Description |
|---|---|---|
y |
ndarray
|
|
xbar |
ndarray
|
|
tau |
float
|
Localisation time. |
step |
int
|
Number of steps taken since the start. |
key_data |
ndarray
|
Raw data of the run's random key. |
key_impl |
str
|
Name of the key's PRNG implementation. |
struct |
pytree of jax.ShapeDtypeStruct
|
Structure of the latent. |
mgsl.save_state(path, state)
¶
Save a state to an .npz file (written to a temporary file, then renamed, so an
existing file is never left half-written).
The file stores the arrays, the observation time and step, the key, and the latent's
structure, shapes and dtypes, which :func:load_state checks.
mgsl.load_state(path, like)
¶
Load a state saved by :func:save_state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str or path - like
|
|
required |
like
|
pytree
|
A latent (arrays or |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the file's format version, structure, shapes or dtypes do not match. |