"""Seed scheme. instance_seed = SHA1(f"{base_seed}|{family}|{instance_index}") mod 2**31 RNG fixed to numpy.random.default_rng (PCG64). `family` is the dotted family name (e.g. "positives.clear_large_training"). """ from __future__ import annotations import hashlib import numpy as np DEFAULT_BASE_SEED = 20260609 RNG_NAME = "numpy.random.default_rng" def instance_seed(base_seed: int, family: str, instance_index: int) -> int: digest = hashlib.sha1(f"{base_seed}|{family}|{instance_index}".encode("utf-8")).hexdigest() return int(digest, 16) % (2 ** 31) def rng_for(base_seed: int, family: str, instance_index: int) -> np.random.Generator: return np.random.default_rng(instance_seed(base_seed, family, instance_index))