RELogger

class jaxrens.io.re_stats_log.RELogger(path, n_pairs, flavor, flush_interval=1000, mode='w', restart_iteration=0)[source]

Bases: BufferedH5Logger

Append-only HDF5 writer for per-fire inter-RE swap counts.

Buffers writes in memory and flushes once the NS iteration index has advanced by flush_interval since the last flush (and on close()). The threshold is in absolute NS iterations; per-walker YAML units are handled upstream by _apply_interval_units. The file is only created on the first flush, so runs without any swap fires never produce an empty artefact.

Parameters:
  • path (Path | str) – Destination file path (.re_stats.h5).

  • n_pairs (int) – Number of adjacent replica pairs (= n_runs - 1). May be 0 (for n_runs < 2) — the writer accepts but a callback should not push such entries.

  • flavor (str) – RE flavor label, one of ‘pressure’, ‘xrens’, ‘semi_grand’. Stored as an HDF5 attr.

  • flush_interval (int) – Flush after the NS iteration index has advanced by this many absolute iterations since the previous flush. Default 1000.

  • mode (str)

  • restart_iteration (int)

write_entry(iteration, n_accepted_per_pair, n_attempted_per_pair)[source]

Buffer one entry. Auto-flushes once the iteration index has advanced by flush_interval absolute iters since the last flush.

Parameters:
  • iteration (int) – NS iteration index (Python int).

  • n_accepted_per_pair (ndarray) – shape (n_pairs,) int.

  • n_attempted_per_pair (ndarray) – shape (n_pairs,) int.

Return type:

None

static read(path)[source]

Load an .re_stats.h5 file into an RELog dataclass.

Parameters:

path (Path | str)

Return type:

RELog