question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bug: NFA doesn't support non-string states

See original GitHub issue
from automata.fa.nfa import NFA

nfa = NFA(
    states={0},
    input_symbols={'0'},
    transitions={0: {}},
    initial_state=0,
    final_states=set()
)

print(nfa.accepts_input(''))

I would expect this to print False, because the NFA has no accepting states. Instead, it throws this error:

File "/usr/local/lib/python3.8/site-packages/automata/base/automaton.py", line 41, in accepts_input
    self.read_input(input_str)
  File "/usr/local/lib/python3.8/site-packages/automata/base/automaton.py", line 34, in read_input
    for config in validation_generator:
  File "/usr/local/lib/python3.8/site-packages/automata/fa/nfa.py", line 120, in read_input_stepwise
    self._check_for_input_rejection(current_states)
  File "/usr/local/lib/python3.8/site-packages/automata/fa/nfa.py", line 104, in _check_for_input_rejection
    ', '.join(current_states)))
TypeError: sequence item 0: expected str instance, int found

Would it be possible to replace ', '.join(current_states) with ', '.join(str(state) for state in current_states), or something along those lines?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
caleb531commented, Aug 17, 2022

@maryembenali Yeah, I think you’re describing a separate issue than this ticket. Can you please create a separate issue so I can look into it? Please include the NFA code you are using, if possible—anything that might help me reproduce the issue on my end.

1reaction
caleb531commented, Mar 20, 2021

@jasonxia17 I think it’s safe to close this issue since I am confident the new tests cover all cases for the bug. Thank you for reporting it!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Are Nondeterministic Finite Automata not allowed 'sink-states'?
A string is accepted by a NFA if there is some path that ends in an accepting state, even if there is a...
Read more >
NFA that does not accept strings ending "101" - Stack Overflow
To accept the string that does not ending with 101 one of the NFA is: ... Here,q0,q1,q2 are final states and q3 is...
Read more >
Error Tokens - cs.wisc.edu
We can define an error token that represents a string terminated by an end of line rather than a double quote character. For...
Read more >
(a) Draw an NFA that accepts the language {w
In this new gadget (with states b,c1,c0), there is now no arrow for 0 coming ... The accepting states are a0, b, and...
Read more >
07 - Non-Deterministic Finite Automata (NFA)
Consider the following NFA: The string aa would not be accepted, because there is no path for aa that leads to an accepting...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found