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

Visualization methods called from command line installation #222

Open
irisdyoung opened this issue May 16, 2024 · 3 comments
Open

Visualization methods called from command line installation #222

irisdyoung opened this issue May 16, 2024 · 3 comments

Comments

@irisdyoung
Copy link

Examining the object my_dfa from the first example directly (no str or dir or anything else) throws an error in the command line only installation (latest, on python 3.12.3, on mac):

ImportError: Missing visualization packages; please install coloraide and pygraphviz.

Is this for sure what you want? It also does return the str representation afterward, so it seems like the error could be downgraded to a warning that you're operating without visualization capabilities, and a pointer to the installation option with the necessary dependencies. Separate issue incoming on that note...

@eliotwrobson
Copy link
Collaborator

I'm a little confused as well, this seems to match the behavior when running in a jupyter notebook without the visualization dependencies installed, but not purely on the command line. Maybe the Mac command line automatically tries to render objects with these methods present?

I suppose we could raise a warning and then the functions will be a noop if these dependencies aren't present? I'm not really sure what other libraries do. @caleb531 any thoughts about this behavior?

@caleb531
Copy link
Owner

caleb531 commented May 16, 2024

@irisdyoung @eliotwrobson I'm not sure I understand the issue here. I pip install automata into a fresh virtualenv (Python 3.12.3 on macOS Sonoma, using Mac terminal), and then run the first example from the FA Examples page, I am able to run the machine without error.

# example1.py
from automata.fa.dfa import DFA

# DFA which matches all binary strings ending in an odd number of '1's
my_dfa = DFA(
    states={'q0', 'q1', 'q2'},
    input_symbols={'0', '1'},
    transitions={
        'q0': {'0': 'q0', '1': 'q1'},
        'q1': {'0': 'q0', '1': 'q2'},
        'q2': {'0': 'q2', '1': 'q1'}
    },
    initial_state='q0',
    final_states={'q1'}
)

try:
    while True:
        if my_dfa.accepts_input(input('Please enter your input: ')):
            print('Accepted')
        else:
            print('Rejected')
except KeyboardInterrupt:
    print('')
Screenshot 2024-05-16 at 2 01 50 PM

@lwasser
Copy link

lwasser commented Jun 7, 2024

linking this to our review - friends can you please link any issues / pr's related to the review back to the review issue so we have a traceable review? many many thanks!! these issues and discussion are fantastic!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants