geneticengine.grammar.utils =========================== .. py:module:: geneticengine.grammar.utils Functions --------- .. autoapisummary:: geneticengine.grammar.utils.has_annotated_mutation geneticengine.grammar.utils.has_annotated_crossover geneticengine.grammar.utils.is_annotated geneticengine.grammar.utils.is_generic_list geneticengine.grammar.utils.is_generic_tuple geneticengine.grammar.utils.is_generic geneticengine.grammar.utils.is_union geneticengine.grammar.utils.get_generic_parameters geneticengine.grammar.utils.get_generic_parameter geneticengine.grammar.utils.strip_annotations geneticengine.grammar.utils.has_arguments geneticengine.grammar.utils.get_arguments geneticengine.grammar.utils.is_abstract geneticengine.grammar.utils.is_terminal geneticengine.grammar.utils.all_init_arguments_typed geneticengine.grammar.utils.strip_dependencies geneticengine.grammar.utils.is_builtin_class_instance geneticengine.grammar.utils.is_metahandler Module Contents --------------- .. py:function:: has_annotated_mutation(ty) Returns whether type has an annotated mutation within metadata. .. py:function:: has_annotated_crossover(ty) Returns whether type has an annotated crossover within metadata. .. py:function:: is_annotated(ty) Returns whether type is annotated with metadata. .. py:function:: is_generic_list(ty) Returns whether a type is List[T] for any T. .. py:function:: is_generic_tuple(ty) Returns whether a type is tuple[X, Y, ...] for any X, Y, .... .. py:function:: is_generic(ty) Returns whether a type is x[T] for any T. .. py:function:: is_union(ty) Returns whether a type is List[T] for any T. .. py:function:: get_generic_parameters(ty) Annotated[T, ] or List[T], this function returns Dict[T,] .. py:function:: get_generic_parameter(ty) When given Annotated[T, ] or List[T], this function returns T. .. py:function:: strip_annotations(ty) When given Annotated[T, ] or List[T], this function recurses with T Otherwise, it returns the parameter unchanged. .. py:function:: has_arguments(n) Returns whether a node has arguments or not. .. py:function:: get_arguments(n) :param n: production :return: list((argname, argtype)) .. py:function:: is_abstract(t) Returns whether a class is a Protocol or AbstractBaseClass. .. py:function:: is_terminal(t, non_terminals) Returns whether a node is a terminal or not, based on the list of non terminals in the grammar. .. py:function:: all_init_arguments_typed(t) .. py:function:: strip_dependencies(s) .. py:function:: is_builtin_class_instance(obj) .. py:function:: 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