Skip to main content

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.

Build Status PyPI version License: MIT

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.2.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

dfa_mutate-0.1.2-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

Details for the file dfa_mutate-0.1.2.tar.gz.

File metadata

  • Download URL: dfa_mutate-0.1.2.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.0 CPython/3.10.9 Linux/5.15.103

File hashes

Hashes for dfa_mutate-0.1.2.tar.gz
Algorithm Hash digest
SHA256 acd53da9a743f02a6494f04fe1155f73b7d567a0ef6911ab0fb06d5cce0b82a5
MD5 4047c51875e608a51e3a4583f9d81dfc
BLAKE2b-256 4c2d9cede1e8ac2f43c3689139f4495d5c4ef054dba2bdee046a214394f46241

See more details on using hashes here.

File details

Details for the file dfa_mutate-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: dfa_mutate-0.1.2-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

Hashes for dfa_mutate-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 baced6ca5d3a2babe3c024d4bdf1f503b74f228b2fce5f60a9d8f6c0b4a416c5
MD5 f5177f6a573801935eb7087dff77b066
BLAKE2b-256 ff6c61b44b9b8dff700578fa48bcf6c74eecedf4096401bb257cf677154d1b29

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page