MaxNeighborsLogger

class jaxrens.io.max_neighbors_log.MaxNeighborsLogger(path, n_runs, n_walkers, flush_interval=1000, mode='w', restart_iteration=0)[source]

Bases: BufferedH5Logger

Append-only HDF5 writer for per-iteration neighbor-bucket diagnostics.

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 the callback never produce an empty artefact.

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

  • n_runs (int) – Number of parallel NS runs (use 1 for SingleRun).

  • n_walkers (int) – Number of walkers per run; sets the per-walker dataset shape only.

  • 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, max_neighbor_count, bucket_size, overflow)[source]

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

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

  • max_neighbor_count (ndarray) – shape (n_runs, n_walkers) or (n_walkers,) for single-run.

  • bucket_size (ndarray) – shape (n_runs,) or scalar for single-run.

  • overflow (ndarray) – shape (n_runs,) or scalar for single-run.

Return type:

None

static read(path)[source]

Load a .max_neighbors.h5 file into a MaxNeighborsLog.

Parameters:

path (Path | str)

Return type:

MaxNeighborsLog