WalkerState

class jaxrens.state.walker.WalkerState(positions, types, energy, cell=None, n_atoms=0)[source]

Bases: object

State of a single walker in configuration space.

JAX-registered pytree. Use .set() for functional updates.

Shape annotations use a variadic batch prefix *B so the same annotation covers a single walker (*B = ()), the live population (*B = (K,)), vmapped runs (*B = (P, K)), and pmap+vmap (*B = (G, P, K)).

Variables:
  • positions (jaxtyping.Float[jaxlib._jax.Array, '*B N 3']) – Cartesian coordinates, shape (*B, n_atoms, 3).

  • types (jaxtyping.Int[jaxlib._jax.Array, '*B N']) – Integer atom type codes, shape (*B, n_atoms).

  • energy (jaxtyping.Float[jaxlib._jax.Array, '*B']) – Current potential energy, shape (*B,).

  • cell (jaxtyping.Float[jaxlib._jax.Array, '*B 3 3'] | None) – Unit cell matrix, shape (*B, 3, 3) or None for non-periodic systems.

  • n_atoms (int) – Number of atoms (compile-time constant).

Parameters:
  • positions (Float[jaxlib._jax.Array, '*B N 3'])

  • types (Int[jaxlib._jax.Array, '*B N'])

  • energy (Float[jaxlib._jax.Array, '*B'])

  • cell (Float[jaxlib._jax.Array, '*B 3 3'] | None)

  • n_atoms (int)

set(**kwargs)[source]

Functional update: return a new WalkerState with specified fields replaced.

Parameters:

kwargs (Any)

Return type:

WalkerState

classmethod from_record(record, *, n_atoms=None)[source]

Build a single-walker WalkerState from a loose serialization dict.

The in-memory walker contract is this dataclass; on-disk artifacts and the callback boundary use plain dicts. This classmethod is the single place that maps those loose keys back to the typed form, so callers stop hand-unpacking walker["positions"] alongside walker.positions.

The unit cell is read from cell or its on-disk alias box (the extxyz/HDF5 writers emit box). Arrays are coerced to JAX arrays so the result satisfies the dataclass’s jaxtyped field contract regardless of whether the record carried numpy or jax arrays.

Single walker only — for a batched population record use jaxrens.io.formats.iter_walker_states().

Parameters:
Return type:

WalkerState