paramset#

class ParameterSet(keys: list[str], values: Sequence[Sequence[Any]])#

Bases: object

Data type that stores a test file’s parameters from which test cases are instantiated. Data is stored in a two-dimensional table given by values with associated column labels given by keys. The number of columns in values must equal the number of keys.

Parameters:
  • keys – names of parameters

  • values – table of values

Notes:

The ParameterSet is most easily created through one of its class factory methods.

describe(indent=0) str#
classmethod list_parameter_space(argnames: str | Sequence[str], argvalues: list[Sequence[Any] | Any], file: str | None = None) ParameterSet#

Create a ParameterSet

Parameters:
  • argnames – comma-separated string denoting one or more parameter names, r a list/tuple of names

  • argvalues – If only one argname was specified, argvalues is a list of values. If N argnames were specified, argvalues is a 2D list of values where each column are the values for its respective argname.

Examples:

>>> p = ParameterSet.list_parameter_space(
... "a,b", [[1, 2], [3, 4]])
>>> p.keys
['a', 'b']
>>> p.values
[[1, 2], [3, 4]]
classmethod centered_parameter_space(argnames: str | Sequence[str], argvalues: list[Sequence[Any] | Any], file: str | None = None) ParameterSet#

Generate parameters for a centered parameter study

Parameters:
  • argnames – Same arguments as for ParameterSpace.list_parameter_space

  • argvalues – 2D list of values * argvalues[i, 0] is the initial value for the ith argname * argvalues[i, 1] is the steps size for the ith argname * argvalues[i, 2] is the number of steps for the ith argname

Notes:

The centered parameter space computes parameter sets along multiple coordinate-based vectors, one per parameter, centered about the initial values.

The centered_parameter_space takes steps along each orthogonal dimension. Each dimension is treated independently. The number of steps are taken in each direction, so that the total number of points in the parameter study is \(1+ 2\sum{n}\).

>>> names, values = centered_parameter_space(
    "name_1,name_2", [(0, 5, 2), (0, 1, 2)]
)
>>> for row in values:
...     print(", ".join(f"{names[i]}={p}" for (i, p) in enumerate(row)))
...
name_1=0, name_2=0
name_1=-10, name_2=0
name_1=-5, name_2=0
name_1=5, name_2=0
name_1=10, name_2=0
name_1=0, name_2=-2
name_1=0, name_2=-1
name_1=0, name_2=1
name_1=0, name_2=2
classmethod random_parameter_space(argnames: str | Sequence[str], argvalues: list[Sequence[Any] | Any], samples: int = 10, random_seed: float = 1234.0, file: str | None = None) ParameterSet#

Generate random parameter space

static combine_old(paramsets: list[ParameterSet]) list[dict[str, Any]]#

Perform a Cartesian product combination of parameter sets

static combine(paramsets: list[ParameterSet]) list[dict[str, Any]]#
random_range(a: float, b: float, n: int) list[float]#
transpose(a: list[list[float]]) list[list[float]]#
append_if_unique(container, item)#
is_scalar(item: Any) bool#