pg.hyper.ManyOf¶
Accessible via pg.hyper.ManyOf
, pg.hyper.ChoiceList
.
- class ManyOf(num_choices=None, candidates=MISSING_VALUE, choices_distinct=True, choices_sorted=False, hints=None, *, name=None, where=None)[source]¶
Bases:
pg.hyper.Choices
N Choose K.
Example:
# Chooses 2 distinct candidates. v = pg.manyof(2, [1, 2, 3]) # Chooses 2 non-distinct candidates. v = pg.manyof(2, [1, 2, 3], distinct=False) # Chooses 2 distinct candidates sorted by their indices. v = pg.manyof(2, [1, 2, 3], sorted=True) # Permutates the candidates. v = pg.permutate([1, 2, 3]) # A hierarchical categorical choice: v2 = pg.manyof(2, [ 'foo', 'bar', pg.oneof([1, 2, 3]) ])
Methods:
custom_apply
(path, value_spec, allow_partial)Validate candidates during value_spec binding time.