automata icon indicating copy to clipboard operation
automata copied to clipboard

Visualization methods called from command line installation

Open irisdyoung opened this issue 1 year ago • 2 comments

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...

irisdyoung avatar May 16 '24 13:05 irisdyoung

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?

eliotwrobson avatar May 16 '24 15:05 eliotwrobson

@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

caleb531 avatar May 16 '24 21:05 caleb531

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!

lwasser avatar Jun 07 '24 18:06 lwasser

@caleb531 I realize we haven't really come to a conclusion here, but should we close this as not planned and reopen if this comes up again? Neither of us was able to reproduce this issue, and nobody else has reported it, so I'm not sure we can really do anything at this point.

eliotwrobson avatar Jun 27 '24 15:06 eliotwrobson

@eliotwrobson Agreed to close as not planned—we can always reopen if need be.

caleb531 avatar Jun 27 '24 17:06 caleb531