-
Notifications
You must be signed in to change notification settings - Fork 193
Enhance docstrings for topological sort methods #1413
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
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 is blocked until I merge a fix for clippy lints, which hopefully is soon
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.
LGTM with a minor caveat
src/dag_algo/mod.rs
Outdated
/// >>> G.add_nodes_from(["A", "B", "C", "D", "E", "F", "G"]) | ||
/// >>> G.add_edges_from_no_data([(0, 6), (1, 6), (2, 6), (3, 6), (4, 6), (5, 6)]) |
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.
Nitpicking, but you can unpack this as:
a, b, c, d, e, f, g = .add_nodes_from(["A", "B", "C", "D", "E", "F", "G"])
And then do e.g. edges_from_no_data[(a, g)...]
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.
In this case it seems to be useful. Updated, thanks.
/// :param PyDiGraph graph: The DAG to get the topological generations from | ||
/// >>> G = rx.PyDiGraph() | ||
/// >>> G.add_nodes_from([0, 1, 2, 3, 4]) | ||
/// >>> G.add_edges_from_no_data([(0, 1), (0, 2), (1, 3), (2, 3), (3, 4)]) |
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.
ditto
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.
The same as below. Here even more: perfectly matching numbers only.
/// | ||
/// >>> G = rx.PyDiGraph() | ||
/// >>> G.add_nodes_from(["A", "B", "C", "D", "E", "F", "G"]) | ||
/// >>> G.add_edges_from_no_data([(0, 1),(1, 2), (2, 3), (3, 4), (5, 2), (6, 3)]) |
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.
ditto
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 is true for many of other examples and I'll be happy to update them later.
However, since this method returns a numerical list of indices NodeIndices[6, 5, 0, 1, 2, 3, 4]
, I find it easier for the reader to match these numbers and the arguments to add_edges_from_no_data
.
And about raising an error: that would probably be the correct behaviour. It should be pretty easy to check after the fact as well, if the rustworxk-core lexicographical topological sort did not return all the nodes we'd raise. |
Pull Request Test Coverage Report for Build 14289021126Details
💛 - Coveralls |
5c65617
to
c3baa27
Compare
Actually, it is unfortunately correct, as it is. Because of the optional |
Just FYI, I think the error from the CI is actionable:
If the fix is trivial, I can try patching it after I merge #1403 |
c3baa27
to
0ef6e00
Compare
0ef6e00
to
ba25dd2
Compare
Once https://status.coveralls.io/ is back we should be able to merge this |
I realized the
lexicographical_topological_sort
method does not raiseDAGHasCycle
if it gets a graph with cycles. It just ignores the participating nodes and returns the rest.For instance:
returns an empty list.
I tried to add a check into the code, but did not succeed. The test in would be: