geneticengine.grammar.metahandlers.base

Attributes

T

Exceptions

SynthesisException

Common base class for all non-exit exceptions.

Classes

MetaHandlerGenerator

MetaHandlers are type refinements.

Module Contents

geneticengine.grammar.metahandlers.base.T
exception geneticengine.grammar.metahandlers.base.SynthesisException

Bases: Exception

Common base class for all non-exit exceptions.

Initialize self. See help(type(self)) for accurate signature.

class geneticengine.grammar.metahandlers.base.MetaHandlerGenerator

Bases: abc.ABC

MetaHandlers are type refinements.

They override the generation procedure of the base type.

abstractmethod validate(Any)
Return type:

bool

abstractmethod generate(random, grammar, base_type, rec, dependent_values, parent_values)

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 :param Callable[[int, Type], Any] rec: 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 :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

  • random (geneticengine.random.sources.RandomSource)

  • grammar (geneticengine.grammar.grammar.Grammar)

  • rec (Callable[[type[T]], T])

  • dependent_values (dict[str, Any])

  • parent_values (list[dict[str, Any]])

Return type:

Any

get_dependencies()