pg.hyper.HyperValue¶
Accessible via pg.hyper.HyperValue.
- class HyperValue[source]¶
Bases:
pg.symbolic.NonDeterministicBase class for a hyper value.
Hyper value represents a space of objects, which is essential for programmatically generating objects. It can encode a concrete object into a DNA, or decode a DNA into a concrete object.
DNA is a nestable numeric interface we use to generate object (see geno.py). Each position in the DNA represents either the index of a choice, or a value itself is numeric. There could be multiple choices standing side-by-side, representing knobs on different parts of an object, or choices being chained, forming conditional choice spaces, which can be described by a tree structure.
Hyper values form a tree as the following:
![digraph relationship {
template [label="ObjectTemplate" href="object_template.html"];
primitive [label="HyperPrimitive" href="hyper_primitive.html"];
choices [label="OneOf/ManyOf" href="choices.html"];
float [label="Float" href="float_class.html"];
custom [label="CustomHyper" href="custom_hyper.html"];
template -> primitive [label="elements (1:*)"];
primitive -> choices [dir="back" arrowtail="empty" style="dashed"];
primitive -> float [dir="back" arrowtail="empty" style="dashed"];
primitive -> custom [dir="back" arrowtail="empty" style="dashed"];
choices -> template [label="candidates (1:*)"];
}](../../../_images/graphviz-558d2ea022c5d6913b3894da2d2e7facb5138eb2.png)
Methods:
decode(dna)Decode a value from a DNA.
dna_spec([location])Get DNA spec of DNA that is decodable/encodable by this hyper value.
encode(value)Encode a value into a DNA.
set_dna(dna)Use this DNA to generate value.
Attributes:
Returns the DNA that is being used by this hyper value.
- abstract dna_spec(location=None)[source]¶
Get DNA spec of DNA that is decodable/encodable by this hyper value.
- Return type: