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

Error when nodes name are string type and int type #25

Closed
dbvdb opened this issue Apr 18, 2019 · 2 comments
Closed

Error when nodes name are string type and int type #25

dbvdb opened this issue Apr 18, 2019 · 2 comments

Comments

@dbvdb
Copy link

dbvdb commented Apr 18, 2019

def _sorted_tuple(t):
    a, b = t
    return (a, b) if a > b else (b, a)

TypeError: '>' not supported between instances of 'str' and 'int'
@rafguns
Copy link
Owner

rafguns commented Apr 24, 2019

Indeed, nodes are assumed to be all of the same type and sortable. Looking at this code again, I wonder if maybe we can just get rid of _sorted_tuple and do sth like this:

def __eq__(self, other):
    try:
        return self.elements == other.elements
    except AttributeError:
        a, b = other
        return self.elements == (a, b) or self.elements == (b, a)

@rafguns
Copy link
Owner

rafguns commented Apr 30, 2019

Fixed in 58ff2e1.

I have kept _sorted_tuple for now: it ensures that the ranking of node pairs is always the same, even in case of ties.

@rafguns rafguns closed this as completed Apr 30, 2019
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

2 participants