Skip to content

Index out of range error #14

@rlorigro

Description

@rlorigro

Hi, I tried to create a dafsa object from the output of dafsa:

from dafsa import DAFSA


def main():
    lines = [
        "+-- #5: n(#6/2:<p>/2) [('p', 6)]",
        "+-- #6: F(#3/2:<s>/1) [('s', 3)]",
        "+-- #8: n(#3/1:<p>/1) [('p', 3)]"
    ]

    d = DAFSA(lines, condense=True)

    d.write_figure("d2.png")


if __name__ == "__main__":
    main()

And the program crashes, unfortunately.

Traceback (most recent call last):
  File "test_dafsa.py", line 17, in <module>
    main()
  File "test_dafsa.py", line 11, in main
    d = DAFSA(lines, condense=True)
  File "/home/ryan/code/tokenizer/venv/lib/python3.8/site-packages/dafsa/dafsa.py", line 461, in __init__
    self.condense()
  File "/home/ryan/code/tokenizer/venv/lib/python3.8/site-packages/dafsa/dafsa.py", line 610, in condense
    if self._joining_round() == 0:
  File "/home/ryan/code/tokenizer/venv/lib/python3.8/site-packages/dafsa/dafsa.py", line 655, in _joining_round
    edge_info = [edge for edge in edges if edge["target"] == node_id][0]
IndexError: list index out of range

Is there a simple fix for this? It works properly when condense=False

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions