Skip to content

autonomy.analyse.abci.app_spec

Generates the specification for a given ABCI app in YAML/JSON/Mermaid format.

DFASpecificationError Objects

class DFASpecificationError(Exception)

Simple class to raise errors when parsing a DFA.

DFA Objects

class DFA()

Simple specification of a deterministic finite automaton (DFA).

OutputFormats Objects

class OutputFormats()

Output formats.

__init__

def __init__(label: str, states: Set[str], default_start_state: str, start_states: Set[str], final_states: Set[str], alphabet_in: Set[str], transition_func: Dict[Tuple[str, str], str])

Initialize DFA object.

is_transition_func_total

def is_transition_func_total() -> bool

Outputs True if the transition function of the DFA is total.

A transition function is total when it explicitly defines all the transitions for all the possible pairs (state, input_symbol). By convention, when a transition (state, input_symbol) is not defined for a certain input_symbol, it will be automatically regarded as a self-transition to the same state.

Returns:

True if the transition function is total. False otherwise.

get_transitions

def get_transitions(input_sequence: List[str]) -> List[str]

Runs the DFA given the input sequence of symbols, and outputs the list of state transitions.

parse_transition_func

def parse_transition_func() -> Dict[str, Dict[str, str]]

Parse the transition function from the spec to a nested dictionary.

__eq__

def __eq__(other: object) -> bool

Compares two DFAs

dump

def dump(file: Path, output_format: str = "yaml") -> None

Dumps this DFA spec. to a file in YAML/JSON/Mermaid format.

dump_json

def dump_json(fp: TextIO) -> None

Dump to a json file.

dump_yaml

def dump_yaml(fp: TextIO) -> None

Dump to a yaml file.

dump_mermaid

def dump_mermaid(fp: TextIO) -> None

Dumps this DFA spec. to a file in Mermaid format.

generate

def generate() -> Dict[str, Any]

Retrieves an exportable representation for YAML/JSON dump of this DFA.

load

@classmethod
def load(cls, fp: TextIO, input_format: str = "yaml") -> "DFA"

Loads a DFA JSON specification from file.

abci_to_dfa

@classmethod
def abci_to_dfa(cls, abci_app_cls: Any, label: str = "") -> "DFA"

Translates an AbciApp class into a DFA.

SpecCheck Objects

class SpecCheck()

Class to represent abci spec checks.

check_one

@staticmethod
def check_one(informat: str, infile: str, classfqn: str) -> bool

Check for one.

check_all

@classmethod
def check_all(cls, packages_dir: Path) -> None

Check all the available definitions.

Back to top