evokit.tools.lineage package
Module contents
- class evokit.tools.lineage.VarySignature[source]
Bases:
Protocol,Generic[D]Signature of
Variator.vary().:meta private
- __init__(*args, **kwargs)
- evokit.tools.lineage.TrackParents(var: Variator[D], max_parents: int = 5) Variator[D][source]
Decorator that lets a variator track the lineage of an offspring.
In particular, each call to
var.varysets theIndividual.parentsof all offspring to its inputs.Warning
To save cost, the
Individual.parentsis reset toNoneafter an individual ever becomes themax_parentsth parent of another individual.If an individual is preserved for several generations, its
Individual.parentsmay be expunged.
- evokit.tools.lineage.register_parents(source_target_links: dict[str, tuple[str, set[str]]], ind: Individual, identifier: Callable[[Individual], str])[source]
- evokit.tools.lineage.uid(x: Individual) str[source]
- evokit.tools.lineage.graph_lineage(individuals: ~typing.Sequence[~evokit.core.population.Individual], identifier: ~typing.Callable[[~evokit.core.population.Individual], str] = <function uid>, use_tooltip: bool = False, vertical_spacing: int = 1, save_as: Optional[Path | str] = None) Digraph[source]
Graph the lineage of an individual. This information can be accessed as
Individual.parents.Linage tracking is off by default.
TrackParents()enables lineage tracking in a variator.- Parameters:
individuals – Individuals to plot.
identifier – A function to convert an individual to a unique identifier. The default
id()is efficient but might not work with individual that have moved out of memory (for example, ones that have beenIndividual.load()ed)use_tooltip – If
True, then the name (string representation) of each node is rendered as a tooltip instead of text. Tooltips are only rendered in SVG filesvertical_spacing – Multiplier for vertical spacing between nodes.
save_as –
Path to save the output as. If name is given, file will be saved as name.svg.
Warning
save_as can traverse to parent directories and overwrite files.