pg.hyper.OneOf¶
Accessible via pg.hyper.OneOf, pg.hyper.ChoiceValue.
- class OneOf(candidates, hints=None, where=None, *, name=None, num_choices=1, choices_distinct=True, choices_sorted=False)[source]¶
Bases:
pg.hyper.ChoicesN Choose 1.
Example:
# A single categorical choice: v = pg.oneof([1, 2, 3]) # A hierarchical categorical choice: v2 = pg.oneof([ 'foo', 'bar', pg.oneof([1, 2, 3]) ])
Methods:
custom_apply(path, value_spec, allow_partial)Validate candidates during value_spec binding time.
encode(value)Encode a value into a DNA.