geneticengine.grammar.metahandlers.vars ======================================= .. py:module:: geneticengine.grammar.metahandlers.vars Attributes ---------- .. autoapisummary:: geneticengine.grammar.metahandlers.vars.T Classes ------- .. autoapisummary:: geneticengine.grammar.metahandlers.vars.VarRange geneticengine.grammar.metahandlers.vars.VarRangeWithProbabilities Module Contents --------------- .. py:data:: T .. py:class:: VarRange(options) Bases: :py:obj:`geneticengine.grammar.metahandlers.base.MetaHandlerGenerator` VarRange([a, b, c]) represents the alternative between a, b, and c. The list of options can be dynamically altered before the grammar extraction with something like Var.__init__.__annotations__["name"] = Annotated[str, VarRange([d, e, f])]. The option list must not be empty. .. py:attribute:: options .. py:method:: validate(v) .. py:method:: generate(random, grammar, base_type, rec, dependent_values, parent_values) Generates an instance of type base_type, according to some criterion. :param Source r: Random source for generation :param Grammar g: Grammar to follow in the generation :param Callable[[int, Type], Any] rec: The method to generate a new instance of type and maximum depth d :param int depth: the current depth budget :param Type base_type: The inner type being annotated :param str argname: The name of the field of the parent object which is being generated :param Dict[str, Type] context: The names and types of all fields in the parent object :param Dict[str, Type] dependent_values: The names and values of all previous fields in the parent object .. py:method:: __repr__() .. py:method:: __class_getitem__(args) :classmethod: .. py:method:: iterate(base_type, combine_lists, rec, dependent_values) .. py:class:: VarRangeWithProbabilities(options, probabilities) Bases: :py:obj:`geneticengine.grammar.metahandlers.base.MetaHandlerGenerator` VarRangeWithProbabilities([a, b, c], [pa, pb, pc]) represents the alternative between a, b, and c with the given probabilities. The options list must not be empty and the probabilities list must have the same length as options. Probabilities can be any non-negative numbers and are interpreted as weights. .. py:attribute:: options .. py:attribute:: probabilities .. py:method:: validate(v) .. py:method:: generate(random, grammar, base_type, rec, dependent_values, parent_values) Generates an instance of type base_type, according to some criterion. :param Source r: Random source for generation :param Grammar g: Grammar to follow in the generation :param Callable[[int, Type], Any] rec: The method to generate a new instance of type and maximum depth d :param int depth: the current depth budget :param Type base_type: The inner type being annotated :param str argname: The name of the field of the parent object which is being generated :param Dict[str, Type] context: The names and types of all fields in the parent object :param Dict[str, Type] dependent_values: The names and values of all previous fields in the parent object .. py:method:: __repr__() .. py:method:: __class_getitem__(args) :classmethod: .. py:method:: iterate(base_type, combine_lists, rec, dependent_values)