Library for mutating a DFA represented using the dfa library.
Project description
DFA Mutate
Primitives and utilities for manipulating deterministic finite automata (DFA) represented using the dfa library.
Table of Contents
Installation
If you just need to use dfa_mutate
, you can just run:
$ pip install dfa_mutate
For developers, note that this project uses the poetry python package/dependency management tool. Please familarize yourself with it and then run:
$ poetry install
Usage
Example Usage:
from dfa import DFA
import dfa_mutate
dfa1 = DFA(
start=0,
inputs={0, 1},
label=lambda s: (s % 4) == 3,
transition=lambda s, c: (s + c) % 4,
)
# Pick a specific mutation.
dfa2 = dfa_mutate.add_state(dfa1)
dfa3 = dfa_mutate.change_start(dfa1)
dfa4 = dfa_mutate.change_transition(dfa1)
dfa5 = dfa_mutate.relabel_state(dfa1)
# Infinite Generator mutations round-robin (will repeat).
dfas = dfa_mutate.generate_mutations(orig)
# Sample DFA using softmax over a scoring function (default constant).
# Uses first n dfas generated by above generator.
# NOTE: requires the optional numpy dependency.
dfa6 = dfa_mutate.sample_mutation(dfa1, n=20, score=lambda d: len(d.states()))
# All functions support passing in random number generator.
import random
dfa7 = dfa_mutate.relabel_state(dfa1, random.Random(0))
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
dfa_mutate-0.1.0.tar.gz
(3.6 kB
view details)
Built Distribution
File details
Details for the file dfa_mutate-0.1.0.tar.gz
.
File metadata
- Download URL: dfa_mutate-0.1.0.tar.gz
- Upload date:
- Size: 3.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.3.0 CPython/3.10.9 Linux/5.15.103
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 379e8e20fbd7b6d0c85dffb62ed82166357be476f4fa93f70a62dab10d8aec6a |
|
MD5 | 48ee3b3da00676742c24a93e542b5af7 |
|
BLAKE2b-256 | bcfcffaf0b6d8487264783f4d3bb831abfb87b17865460cdae5f91b8f5f377cb |
File details
Details for the file dfa_mutate-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: dfa_mutate-0.1.0-py3-none-any.whl
- Upload date:
- Size: 3.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.3.0 CPython/3.10.9 Linux/5.15.103
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 780c0761021e0173b050f8dc6cba48b80d39579ede6e9172390f9a85aa5d09ab |
|
MD5 | 8fb2bb98cda2ef2f03fcf1f62b2d474c |
|
BLAKE2b-256 | 1061128b08c3b97e8e7a6b8249a562411eb221ce10b77110d8318865a3d6843f |