-
-
Notifications
You must be signed in to change notification settings - Fork 35
MAINT: Renaming functions with a different name while dispatching #56
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,18 +5,25 @@ | |
| import nx_parallel as nxp | ||
|
|
||
| __all__ = [ | ||
| "all_pairs_node_connectivity", | ||
| "approximate_all_pairs_node_connectivity", | ||
| ] | ||
|
|
||
|
|
||
| def all_pairs_node_connectivity(G, nbunch=None, cutoff=None, get_chunks="chunks"): | ||
| def approximate_all_pairs_node_connectivity( | ||
| G, nbunch=None, cutoff=None, get_chunks="chunks" | ||
| ): | ||
| """The parallel implementation first divides the a list of all permutation (in case | ||
| of directed graphs) and combinations (in case of undirected graphs) of `nbunch` | ||
| into chunks and then creates a generator to lazily compute the local node | ||
| connectivities for each chunk, and then employs joblib's `Parallel` function to | ||
| execute these computations in parallel across all available CPU cores. At the end, | ||
| the results are aggregated into a single dictionary and returned. | ||
|
|
||
| Note, this function uses the name `approximate_all_pairs_node_connectivity` while | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also, added this to make the user aware that this function uses a different name while dispatching.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought that users would never call this function directly -- that is, they would call the networkx function which in turn would call the appropriate function for them. Do I understand the public facing api correctly?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we are that strict about how someone "should" use a backend and a backend is also a package. So, I added this for someone who might want to call nx_parallel's implementation directly for their graph(like if the cost of dispatching through networkx to nx-parallel is too much for their case). But, as mentioned in the note added in README(in this PR) it's not the recommended way. If you think it's too much info to put in the main docs, then let me know, I can remove it and just keep(or maybe change a little) the first note in README.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK... and I have a question: in the README file just after the paragraph describing this, the examples says: But is this right? I was thinking that the dispatcher calls the backend using the function If I am right, we could allow both in the nx-parallel package (if you want to allow that) by including both routes to the name in the
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you very much for pointing this out! |
||
| dispatching to the backend in=mplementation. So, `nxp.all_pairs_node_connectivity` | ||
| will run the parallel implementation of `all_pairs_node_connectivity` present in the | ||
| `connectivity/connectivity`. Use `nxp.approximate_all_pairs_node_connectivity` instead. | ||
|
|
||
| Parameters | ||
| ------------ | ||
| get_chunks : str, function (default = "chunks") | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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.
If you want to allow both ways to call the functions, we could do something like
and then below (after defining the longer named function) use
But I'm fine with this PR as is. Which do you prefer?
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.
while generating the
get_infofunction we fetch all the functions in the nx_parallel package and then extract their docstrings... so having 2all_pairs_node_connectivityfunctions in the package(one of them being inconnectivity/connectivity(with docstring) and the other one being inapproximation/connectivity(without docstring)) would probably result in an incorrect mapping between functions and theadditional_docs. So, for now, I'd prefer the current implemented way, although this way does allow the user to use nx-parallel as an independent package, so I'd like to try and find if there's a better way to generateget_info. But, I think that's for another PR.