pymargins.grid

pymargins.grid(*, label_fmt: str | None = None, **variables)

Cartesian product of variable values into a scenario list.

Parameters:
  • label_fmt (str, optional) – Format string for labels. If None, defaults to a comma-joined "var=val" pattern.

  • **variables – Keyword arguments where each key is a variable name and each value is a list of levels.

Returns:

scenarios

Return type:

list[dict]

Examples

>>> scenarios = grid(age=[30, 50, 70], treatment=[0, 1])
>>> len(scenarios)
6
>>> scenarios[0]
{"atexog": {"age": 30, "treatment": 0}, "label": "age=30, treatment=0"}