Code Monkey home page Code Monkey logo

dfa's People

Contributors

ameesh-shah avatar mvcisback avatar sjunges avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

dfa's Issues

Failed to compose DFAs

Hi,
I started using the package and tried to run the following code described at the README:

parity = DFA(
    start=0, inputs={0, 1}, label=lambda s: s,
    transition=lambda s, c: (s + c) & 1,
)

self_composed = parity | parity

assert self_composed.label([(0, 0), (1, 0)]) == (1, 0)

and I'm getting the following error:

TypeError: unsupported operand type(s) for |: 'DFA' and 'DFA'

Incompatibility with dill (and pickle)

dfa objects are incompatible with both pickle and dill.

import dfa
import dill

dfa1 = dfa.DFA(start=0,
               inputs = {0,1},
               label=lambda s: (s % 4) == 3,
               transition=lambda s, c: (s + c) % 4,
       )

with open('temp.dill', 'wb') as f:
    dill.dump(dfa1, f)

This code fails with error _pickle.PicklingError: Can't pickle <function _make_lookuper.<locals>.make_lookuper at 0x102a2b5e0>: it's not found as funcy.calc._make_lookuper.<locals>.make_lookuper.

Paths can infinite loop when iteratively getting words from a DFA

In paths(...) in dfa/utils.py, there is a potential for an infinite loop when there are only a finite number of paths available for a given DFA, but paths is called a greater number of times than that.

@mvcisback and I discovered this issue when iterating on DFAs that were the result of XOR operations between two existing DFAs.

Minor: Creating DFA with outputs=None fails.

The following code fails, which is slightly unexpected:

dfa1 = DFA(
    start=0,
    inputs={0, 1},
    outputs=None,
    label=lambda s: (s % 4) == 3,
    transition=lambda s, c: (s + c) % 4,
)

I would expect this to be the same as not setting any outputs.
Setting an empty dictionary yields problems with the lstar library.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.