Bug: NFA doesn't support non-string states
See original GitHub issuefrom 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:
- Created 3 years ago
- Comments:8 (5 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@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.
@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!