Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improving the documentation #54

Open
Buitragox opened this issue Dec 4, 2024 · 2 comments
Open

Improving the documentation #54

Buitragox opened this issue Dec 4, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@Buitragox
Copy link
Contributor

Hi Robin, I'm currently working on rewriting a lot of the current documentation for better readability.

I found an inconsistency while rewriting the documentation of the renumber method from nfa.md. It says, "The new states will
be named as q0, q1, q2, and so on."

But this is what I get with the following code:

from automathon import NFA

q = {'state1', 'state2', 'state3', 'state4'}
sigma = {'0', '1'}
delta = {
    'state1' : {
            '0' : {'state1'},
            '1' : {'state1', 'state2'}
            },
    'state2' : {
            '0' : {'state3'},
            '' : {'state3'}
            },
    'state3' : {
            '1' : {'state4'},
            },
    'state4' : {
            '0' : {'state4'},
            '1' : {'state4'},
            },
}
initial_state = 'state1'
f = {'state4'}

automaton = NFA(q, sigma, delta, initial_state, f)

print(automaton.q) # {'state2', 'state3', 'state1', 'state4'}

automaton.renumber()

print(automaton.q) # {'0', '2', '3', '1'}

It's renaming them to numbers and not putting a 'q' as a prefix. Is this intended and the documentation is incorrect? Or is this a bug?

@rohaquinlop rohaquinlop added the bug Something isn't working label Dec 4, 2024
@rohaquinlop
Copy link
Owner

Hey @Buitragox thank you for your contribution! That's an error, isn't intended to work like that. I think that should be interesting to add an optional argument like prefix = "q" to allow the user to use a custom prefix.

class NFA:
    ...
    def renumber(self, states_prefix = "q") -> None:
    ...

If you want, you can open a PR with this refactor :)

@Buitragox
Copy link
Contributor Author

If you want, you can open a PR with this refactor :)

Sure, I'll be working on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants