pg.geno.Choices¶
Accessible via pg.geno.Choices
.
- class Choices(num_choices=1, candidates=MISSING_VALUE, literal_values=None, distinct=True, sorted=False, subchoice_index=None, hints=None, location=, name=None)[source]¶
Bases:
pg.geno.DecisionPoint
Represents a single or multiple choices from a list of candidates.
Example:
# Create a single choice with a nested subspace for candidate 2 (0-based). pg.geno.oneof([ pg.geno.constant(), pg.geno.constant(), pg.geno.space([ pg.geno.floatv(0.1, 1.0) pg.geno.manyof(2, [ pg.geno.constant(), pg.geno.constant(), pg.geno.constant() ]) ]) ])
See also:
pg.geno.oneof
,pg.geno.manyof
.Methods:
candidate_index
(choice_value)Returns the candidate index of a choice value.
format
([compact, verbose, root_indent, show_id])Format this object.
format_candidate
(index[, display_format])Get a formatted candidate value by index.
subchoice
(index)Returns spec for choice i.
validate
(dna)Validate whether a DNA value conforms to this spec.
Attributes:
Returns all choice specs.
Returns all decision points in their declaration order.
Returns True if current node is a categorical choice.
Returns True if current node is a custom decision point.
Returns True if current node is numerical decision.
Returns if current choice is a subchoice of a multi-choice.
Returns the search space size.
- candidate_index(choice_value)[source]¶
Returns the candidate index of a choice value.
- Return type:
- Parameters:
choice_value – Choice value can be: a (integer, float or string) as a candidate’s literal value, or a text in the format “<index>/<num_candidates>” or a text in the format “<index>/<num_candidates> (<literal>)”.
- Returns:
The index of chosen candidate.
- Raises:
ValueError – choice_value is not a valid index or it does not matches
any candidate's literal value. –
- property decision_points: List[DecisionPoint][source]¶
Returns all decision points in their declaration order.
- Returns:
All decision points in current space. For multi-choices, the sub-choice objects will be returned. Users can call spec.parent_choice to access the parent multi-choice node.
- format(compact=True, verbose=True, root_indent=0, show_id=True, **kwargs)[source]¶
Format this object.
- format_candidate(index, display_format='choice_and_literal')[source]¶
Get a formatted candidate value by index.
- property is_custom_decision_point: bool[source]¶
Returns True if current node is a custom decision point.