-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Improve special cases in dispatch testing (paying off tech debt) #7982
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
Improve special cases in dispatch testing (paying off tech debt) #7982
Conversation
|
No changes to |
|
|
||
| @np_random_state(3) | ||
| @nx._dispatchable(returns_graph=True) | ||
| @nx._dispatchable(preserve_edge_attrs={"G": {"weight": 1}}, returns_graph=True) |
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.
Recall that whenever we see the pattern preserve_edge_attrs={"G": {"weight": 1}}, this means that is it using "weight" edge attributes implicitly, and the function may be a good candidate to add e.g. weight="weight" argument to.
rossbar
left a comment
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 LGTM, thanks for the iterations @eriknw !
dschult
left a comment
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.
Thanks @eriknw for this cleanup and improvement!
These changes are intended to unblock #7902 (CC @rossbar) and to try to make dispatch tests more maintainable (see #7904).
This actually took a lot of experimentation, and I suspect there's even more debt we could pay off, but I think this is a nice increment. To summarize:
We are more methodological about when we create two different arguments to run with the backend and with networkx. As before, we run with networkx and compare results when the result is a graph. In this case, we check that the output graphs match exactly, and return the networkx graph in order to preserve iteration order (b/c some tests are sensitive). We are more careful about doing this when functions mutate input graphs--we now ensure that input graphs are different when calling the function with both the backend and with networkx. @rossbar, I think this is why the latest attempted "fix" for #7902 didn't work--an input graph was mutated, then used in a subsequent call.
This PR deletes a lot of weird, bespoke code that I suspect nobody understands and is likely to be difficult to maintain. This code was originally added so tests would pass. Now we have a different (and less bespoke) way for tests to pass.
This also adds a feature: we compare that input graphs are (very loosely) equal for functions that mutate input graphs. This makes the tests more strict and may affect backends.
Generally, making any changes to this code has a risk of affecting backends.
nx-cugraphhas a few test failures when run against this PR, but I think at least some are true failures.This code is still more complicated than I would prefer, but we're doing something pretty complex, and I believe enabling backends to run networkx tests is worth the trouble.