geneticengine.grammar.metahandlers.ints ======================================= .. py:module:: geneticengine.grammar.metahandlers.ints Attributes ---------- .. autoapisummary:: geneticengine.grammar.metahandlers.ints.min geneticengine.grammar.metahandlers.ints.max geneticengine.grammar.metahandlers.ints.T Classes ------- .. autoapisummary:: geneticengine.grammar.metahandlers.ints.IntRange geneticengine.grammar.metahandlers.ints.IntervalRange Module Contents --------------- .. py:data:: min .. py:data:: max .. py:data:: T .. py:class:: IntRange(min, max) Bases: :py:obj:`geneticengine.grammar.metahandlers.base.MetaHandlerGenerator` IntRange(a,b) restricts ints to be between a and b. The range can be dynamically altered before the grammar extraction Int.__init__.__annotations__["value"] = Annotated[int, IntRange(c,d)] .. py:attribute:: min .. py:attribute:: max .. 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:: validate(v) .. py:method:: iterate(base_type, combine_lists, rec, dependent_values) .. py:method:: __class_getitem__(args) :classmethod: .. py:method:: __repr__() .. py:class:: IntervalRange(minimum_length, maximum_length, maximum_top_limit) Bases: :py:obj:`geneticengine.grammar.metahandlers.base.MetaHandlerGenerator` This metahandler restricts the creation of ranges between two integers by forcing a minimum and maximum range size, as well as a top limit that the range can reach. This is useful in genomics to generate random windows of variable size to scan an input sequence :param int minimum_length: Minimum length possible when randomly generating the range :param int maximum_length: Maximum length possible when randomly generating the range :param int maximum_top_limit: Maximum value the range can reach .. py:attribute:: minimum_length .. py:attribute:: maximum_length .. py:attribute:: maximum_top_limit .. py:method:: __class_getitem__(args) :classmethod: .. 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:: validate(v) .. py:method:: iterate(base_type, combine_lists)