pyfli.data_cc.config_combinations#

Cartesian-product config generator with optional weighted sampling.

Classes

ConfigCombinationGenerator(base_config, sweep)

class ConfigCombinationGenerator(base_config, sweep, weights=None, combo_overrides=None)[source]#

Bases: object

Parameters:
  • base_config (dict) – Full config dict. Keys not listed in sweep are held fixed across every generated combination.

  • sweep (dict[str, list]) –

    Maps a config key to the list of values it should take on, e.g.

    {“jitter”: [True, False], “n_cycles”: [1e5, 5e5, 1e6, 2e6]}

    Total combinations = product of len(v) over all sweep keys.

  • weights (dict[str, list[float]], optional) – Per-key sampling weights, same order/length as the matching sweep list. Keys omitted here default to uniform weighting. A combination’s weight is the product of its per-key weights (i.e. keys are treated as independent), then renormalized to sum to 1. Only affects .sample() — .all_combinations() is always exhaustive and order-preserving regardless of weights.

  • combo_overrides (dict[tuple, float], optional) – Escape hatch for when independence isn’t good enough: maps a specific tuple of values (in sweep key order, e.g. (True, 1e6)) to a weight multiplier applied on top of the per-key product weight for that exact combination.

property n_combinations: int#
all_combinations()[source]#

Yield every combination exactly once (deterministic, exhaustive).

Return type:

Iterable[dict[str, Any]]

combination_table()[source]#

Return (all configs, their sampling probabilities) — for inspection.

Return type:

tuple[list[dict[str, Any]], ndarray]

sample(n=1, seed=None, replace=True)[source]#

Draw n configs according to the weighted distribution.

Parameters:
Return type:

list[dict[str, Any]]