-
Notifications
You must be signed in to change notification settings - Fork 27
Enable edge/path sorting #22
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
Conversation
Enable deterministic extract_metapaths ordering
hetio/hetnet.py
Outdated
@@ -200,6 +203,13 @@ def __hash__(self): | |||
def __eq__(self, other): | |||
return (type(other) is type(self)) and (self.edges == other.edges) | |||
|
|||
def __lt__(self, other): | |||
if len(self) < len(other): |
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.
Would this be clear enough?
def __lt__(self, other):
if len(self) != len(other):
return len(self) < len(other)
return self.edges < other.edges
What you have is fine too, though.
metapaths_with_inverses.add(covered_metapath) | ||
return metapaths | ||
if exclude_inverts: | ||
metapath, _ = sorted([metapath, metapath.inverse]) |
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.
Nice
test/extract_metapaths_test.py
Outdated
# Test metapaths are sorted | ||
abbreviations = [str(metapath) for metapath in metapaths] | ||
assert abbreviations[:4] == [ | ||
'CtD', |
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.
Top two should be swapped
Enable deterministic extract_metapaths ordering