geneticengine.grammar.metahandlers.base
Module Contents
Classes
MetaHandlers are type refinements. |
Functions
|
Returns if type is a metahandler. AnnotatedType[int, IntRange(3,10)] is |
- class geneticengine.grammar.metahandlers.base.MetaHandlerGenerator
Bases:
Protocol
MetaHandlers are type refinements.
They override the generation procedure of the base type.
- 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
- geneticengine.grammar.metahandlers.base.is_metahandler(ty)
Returns if type is a metahandler. AnnotatedType[int, IntRange(3,10)] is an example of a Metahandler.
Verification is done using the __metadata__, which is the first argument of Annotated
- Parameters:
ty (type)
- Return type:
bool