-
Notifications
You must be signed in to change notification settings - Fork 64
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
Added show_diagram
method for Push Down Automata
#177
Conversation
@Vipul-Cariappa To answer your question, I would personally prefer that the stack operation show for each transition because in principle, you want the diagram to be a visual representation of the machine. And changes to the stack can drastically affect the machine's behavior for a PDA. @eliotwrobson Do you have any thoughts on any of this? |
@caleb531 I have updated the code to also display the stack operations. Results: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some early comments. Overall looks good, but needs some test cases and I think some things can be simplified significantly. Thanks for the contribution @Vipul-Cariappa !
I'm in agreement @caleb531 , it's nice to be able to generate the states of the stack along with the visual representation of the machine. @Vipul-Cariappa, it would be awesome to have a flag enabling displaying only the machine or only the stack (both by default). |
@eliotwrobson, I have implemented the feature you asked for. I have refactored the code to remove duplications, to the best of my abilities, according to what I felt makes sense. Please have a look at it, and let me know if any other changes are required. Two things left to do:
|
I have added test cases. Again, I adapted test cases from |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New changes are looking good, in particular the tests seem fairly comprehensive! Left comments in a few places, I think some logic can be simplified significantly and there were a few things I had questions about.
I have made some of the changes @eliotwrobson suggested. Also, left some clarifications and questions. |
f2a95fd
to
08b176e
Compare
I guess all change requests are implemented. Please have a look. Let me know if I missed any. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't want to approve quite yet (as I'd like a little more time to review everything, and requested a few changes), but this is getting very close to being ready to merge!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want to double check whatever is going on with the closing bracket in the unresolved discussion, but the code looks good!
EDIT: Resolved the above. @caleb531 I would say go ahead and merge if you think everything looks good. Would prefer to have another set of eyes before merging just because of the volume of changes.
@eliotwrobson I won't have time to review it today, but I can probably look tomorrow or Monday. In the meantime, could you please add some tests for the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@eliotwrobson @Vipul-Cariappa This PR looks very good! I only have one requested change (well, technically two, I suppose) related to the new DiagramException
class. But if one of you could please make those couple changes quick, I'll be ready to give this the final sign-off!
Thanks also to both of you for all your hard work on this PR so far.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@eliotwrobson Thanks for that! Everything looks good to me now. Approving and merging...
Implemented the
show_diagram
method for Push Down Automata.I have just adapted the
FA.show_diagram
(Finite Automata) code forPDA.show_diagram
.I have not yet implemented
show_diagram
withinput_str
. I will require some suggestions here. Should I also show the operations performed on the stack, or only the state transitions are sufficient?I have not tested the code, except for
DPDA
andNPDA
in the docs. I have attached the images below.DPDA:
NPDA:
Reminder for myself and the maintainer: I should also update the docs to reflect the new feature, before merging this PR.
Hope this is helpful. Please let me know if any changes are required.
Edited:
I have implemented the construction of the diagram with an
input_str
.DPDA from docs with
input_str = "aabb"
:NPDA from docs with
input_str = "abba"
:I have updated the docs. I should now write down some test cases.