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

IndexError in edge.py #91

Open
IngoScholtes opened this issue Apr 19, 2021 · 2 comments
Open

IndexError in edge.py #91

IngoScholtes opened this issue Apr 19, 2021 · 2 comments
Labels
bug Something isn't working

Comments

@IngoScholtes
Copy link
Member

I occasionally observe weird IndexError exceptions like, e.g. in the following case for a HigherOrderNetwork n2:

> [ (x.v.uid, x.w.uid) for x in n2.edges ]

[('1-3', '3-10'),
 ('1-3', '3-29'),
 ('1-3', '3-28'),
 ('1-3', '3-4'),
 ('1-3', '3-9'),
 ('1-3', '3-2'),
 ('1-3', '3-33'),
 ('1-3', '3-14'),
 ('1-3', '3-1'),
 ('1-3', '3-1'),
 ('1-3', '3-8'),
 ('1-3', '3-2')]

> ('1-3', '3-2') in n2.edges
True 

> n2.edges[('1-3', '3-2')]

---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-37-533ded6bd32b> in <module>
----> 1 n2.edges[('1-3', '3-2')]

c:\users\ingos\documents\workbench\pathpy3\pathpy\models\higher_order_network.py in __getitem__(self, key)
    433                 edge = self._nodes_map[_node]
    434             else:
--> 435                 edge = self._nodes_map[_node][-1]
    436 
    437         elif isinstance(key, self._edge_class) and key in self:

c:\users\ingos\documents\workbench\pathpy3\pathpy\core\edge.py in __getitem__(self, key)
    492             edge = key
    493         elif isinstance(key, (int, slice)):
--> 494             edge = list(self._map.values())[key]
    495         else:
    496             edge = self._map[key]

IndexError: list index out of range
@IngoScholtes IngoScholtes added the bug Something isn't working label Apr 19, 2021
@IngoScholtes IngoScholtes added this to the pathpy3 Beta Release milestone Apr 19, 2021
@hackl
Copy link
Collaborator

hackl commented Apr 20, 2021

Strange, why is an int or slice detected instead of a str? I will have a look.

@hackl
Copy link
Collaborator

hackl commented Apr 21, 2021

How did you generate n2? In the edge list the edge ('1-3', '3-2') appears twice, which should not be possible, since each edge should be unique. It might be related to commit d4cb538.

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