-
Notifications
You must be signed in to change notification settings - Fork 27
CycleError: Report all nodes #159
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
base: main
Are you sure you want to change the base?
Conversation
pytools/graph.py
Outdated
| def __init__(self, node: T) -> None: | ||
| self.node = node | ||
| def __init__(self, nodes: List[T]) -> None: | ||
| self.nodes = nodes |
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.
This breaks backward compatibility.
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.
How can I avoid that - maybe by providing a nodes parameter (with a default of None) in addition to the node parameter?
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.
What do you think of c39afca?
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 think a better approach would be to make node a @property that spews a DeprecationWarning.
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.
Implemented in 8823bca
pytools/graph.py
Outdated
| raise CycleError(list(n for n, num_preds in | ||
| nodes_to_num_predecessors.items() if num_preds != 0)) |
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.
It would be nice to provide this in traversable (rather than arbitrary) order, which is doable at
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'm not sure how to do that - how would we provide this in case there are multiple cycles in the graph?
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.
#167 has some work in this direction
|
Unsubscribing... @-mention or request review once it's ready for a look or needs attention. |
282ed93 to
e877f4f
Compare
e877f4f to
9d84d83
Compare
9d84d83 to
bf70743
Compare
de58acc to
c39afca
Compare
|
Also worth referring to the suggestions in this PR: https://gitlab.tiker.net/inducer/pytools/-/merge_requests/37. |
5bbfbbb to
1462f72
Compare
pytools/graph.py
Outdated
| def __init__(self, node: T) -> None: | ||
| self.node = node | ||
| def __init__(self, nodes: List[T]) -> None: | ||
| self.nodes = nodes |
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 think a better approach would be to make node a @property that spews a DeprecationWarning.
pytools/graph.py
Outdated
| :attr node: Node in a directed graph that is part of a cycle. | ||
| :attr nodes: List of nodes in a directed graph that are part of a cycle. |
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.
Maybe path is a better name. Also state that we claim that node[i+1] in path is a successor of node[i] (and test that!).
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.
No description provided.