Complementary parameter groups
Complementary parameter groups consist of N
parameters where each one is accompanied by a rule describing how this parameter can be computed from the N-1
others. When specifying such a group you must specify exactly N-1
parameters and the missing one will be computed automatically.
For example: Consider a rectangle parametrized by width
, height
and area
. Only two of those parameters are needed to have full information and the third one can be computed from the others.
class Rectangle(Configurable):
size = ComplementaryGroup(
(Integer('width'), lambda height, area: area / height),
(Integer('height'), lambda width, area: area / width),
(Integer('area'), lambda width, height: width * height)
)
Each parameter must be accompanied by a conversion rule. The remaining parameters' values are passed by position to the conversion rule.
The ComplementaryGroup
supports a path
argument to define sections for parameters of that group (will be prepended to their names).