geneticengine.grammar.synthetic_grammar ======================================= .. py:module:: geneticengine.grammar.synthetic_grammar Attributes ---------- .. autoapisummary:: geneticengine.grammar.synthetic_grammar.A Functions --------- .. autoapisummary:: geneticengine.grammar.synthetic_grammar.create_dataclass_dynamically geneticengine.grammar.synthetic_grammar.make_non_terminal_names geneticengine.grammar.synthetic_grammar.make_non_terminal_class geneticengine.grammar.synthetic_grammar.make_production geneticengine.grammar.synthetic_grammar.select_random geneticengine.grammar.synthetic_grammar.create_arbitrary_grammar Module Contents --------------- .. py:function:: create_dataclass_dynamically(name, args = {}, annotations = {}, parent_class = ABC) Dynamically creates a new data class with the given name and arguments. :param name: the name of the new data class :type name: str :param args: the attributes and values for the new data class. Default is an empty dictionary. :type args: dict[str, Any] :param annotations: the type annotations for the new data class. Default is an empty dictionary. :type annotations: dict[str, Any] :param parent_class: the parent class for the new data class. Default is ABC (abstract base class). :type parent_class: type :returns: The new data class created .. py:function:: make_non_terminal_names(count) Returns a list of names for non_terminal_symbols. .. py:function:: make_non_terminal_class(name) Returns a new abstract class, with the provided name. .. py:function:: make_production(index, nt, field_types) Creates a class representing a Production. .. py:data:: A .. py:function:: select_random(rd, how_many, candidates) .. py:function:: create_arbitrary_grammar(seed, non_terminals_count, recursive_non_terminals_count, productions_per_non_terminal = lambda rd: round(rd.uniform(1, 10)), non_terminals_per_production = lambda rd: round(rd.uniform(0, 10)), base_types = {int, bool}) Generates a random grammar, based on a particular seed.