geneticengine.grammar.metahandlers.ints
Module Contents
Classes
IntRange(a,b) restricts ints to be between a and b. |
|
IntList([a_1, .., a_n]) restricts ints to be an element from the list. |
|
This metahandler restricts the creation of ranges between two integers |
Attributes
- geneticengine.grammar.metahandlers.ints.min
- geneticengine.grammar.metahandlers.ints.max
- class geneticengine.grammar.metahandlers.ints.IntRange(min, max)
Bases:
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)]
- generate(r, g, rec, new_symbol, depth, base_type, context)
Generates an instance of type base_type, according to some criterion.
- Parameters:
r (Source) – Random source for generation
g (Grammar) – Grammar to follow in the generation
rec (Callable[[int, Type], Any]) – The method to generate a new instance of type and maximum depth d
depth (int) – the current depth budget
base_type (Type) – The inner type being annotated
argname (str) – The name of the field of the parent object which is being generated
context (dict[str, str]) – The names and types of all fields in the parent object
context
- classmethod __class_getitem__(args)
- __repr__()
Return repr(self).
- class geneticengine.grammar.metahandlers.ints.IntList(elements)
Bases:
geneticengine.grammar.metahandlers.base.MetaHandlerGenerator
IntList([a_1, .., a_n]) restricts ints to be an element from the list.
[a_1, .., a_n].
- The range can be dynamically altered before the grammar extraction
Int.__init__.__annotations__[“value”] = Annotated[int, IntList[a_1, .., a_n]]
- generate(r, g, rec, new_symbol, depth, base_type, context)
Generates an instance of type base_type, according to some criterion.
- Parameters:
r (Source) – Random source for generation
g (Grammar) – Grammar to follow in the generation
rec (Callable[[int, Type], Any]) – The method to generate a new instance of type and maximum depth d
depth (int) – the current depth budget
base_type (Type) – The inner type being annotated
argname (str) – The name of the field of the parent object which is being generated
context (dict[str, str]) – The names and types of all fields in the parent object
context
- classmethod __class_getitem__(args)
- __repr__()
Return repr(self).
- class geneticengine.grammar.metahandlers.ints.IntervalRange(minimum_length, maximum_length, maximum_top_limit)
Bases:
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
- Parameters:
minimum_length (int) – Minimum length possible when randomly generating the range
maximum_length (int) – Maximum length possible when randomly generating the range
maximum_top_limit (int) – Maximum value the range can reach
- classmethod __class_getitem__(args)
- generate(r, g, rec, new_symbol, depth, base_type, context)
Generates an instance of type base_type, according to some criterion.
- Parameters:
r (Source) – Random source for generation
g (Grammar) – Grammar to follow in the generation
rec (Callable[[int, Type], Any]) – The method to generate a new instance of type and maximum depth d
depth (int) – the current depth budget
base_type (Type) – The inner type being annotated
argname (str) – The name of the field of the parent object which is being generated
context (dict[str, str]) – The names and types of all fields in the parent object
context