-
-
Notifications
You must be signed in to change notification settings - Fork 30
Refactor get_all_functions to use inspect.signature instead of inspect.getfullargspe #104
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
nx_parallel/tests/test_get_chunks.py
Outdated
signature = inspect.signature(obj) | ||
args = [ | ||
param.name | ||
for param in signature.parameters.values() | ||
if param.kind | ||
in ( | ||
inspect.Parameter.POSITIONAL_ONLY, | ||
inspect.Parameter.POSITIONAL_OR_KEYWORD, | ||
) | ||
] | ||
kwargs = [ | ||
param.name | ||
for param in signature.parameters.values() | ||
if param.kind == inspect.Parameter.KEYWORD_ONLY | ||
] |
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 checked the tests are passing(using pytest nx_parallel
). The CI test failure is unrelated!
Maybe we can simplify this code by only returning kwargs instead of both args and kwargs as get_chunks
is always a kwarg. Does that sound like a good idea to you?
nx_parallel/tests/test_get_chunks.py
Outdated
for edge in G.edges: | ||
assert math.isclose( | ||
c1.get(edge, 0), c2.get(edge, 0), abs_tol=1e-16 | ||
) |
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.
Good catch! But this will now work with edge_betweenness_centrality
and not betweenness_centrality
because for the later the keys are nodes not edges. But, this seems like it is working because when you apply get
on edges it always returns 0
for both c1 and c2. But, that shouldn't happen. So maybe we should use c1.keys
instead of G.nodes(or G.edges). LMKWYT.
@@ -121,11 +121,12 @@ The default chunking in nx-parallel is done by slicing the list of nodes (or edg | |||
- The algorithm that you are considering to add to nx-parallel should be in the main networkx repository and it should have the `_dispatchable` decorator. If not, you can consider adding a sequential implementation in networkx first. | |||
- check-list for adding a new function: | |||
- [ ] Add the parallel implementation(make sure API doesn't break), the file structure should be the same as that in networkx. | |||
- [ ] add the function to the `BackendInterface` class in [interface.py](./nx_parallel/interface.py) (take care of the `name` parameter in `_dispatchable` (ref. [docs](https://networkx.org/documentation/latest/reference/backends.html))) | |||
- [ ] Include the `get_chunks` additional parameter. Currently, all algorithms in nx-parallel offer the user to pass their own custom chunks. Unless it is impossible to chunk, please do include this additional 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.
Could you consider rebasing this branch -- so that these changes don't appear in the diff? Thanks!
I agree with you @Schefflera-Arboricola! I've made the changes you suggested. |
This PR addresses issue #94
Changes made :
Replaced
inspect.getfullargspec()
withinspect.signature()
for reporting the signature of the original function and not that of wrapped.Updated the assertion logic in the
test_get_chunks
forchk_dict_vals
to iterate over graph edges instead of nodes sincechk_dict_vals
consists of functions that deals with edges between the nodes and not the nodes themselves.