refactor test_get_functions_with_get_chunks#128
refactor test_get_functions_with_get_chunks#128Schefflera-Arboricola merged 6 commits intonetworkx:mainfrom
test_get_functions_with_get_chunks#128Conversation
|
|
||
| def test_get_functions_with_get_chunks(): | ||
| # TODO: Instead of `expected` use ALGORTHMS from interface.py | ||
| # take care of functions like `connectivity.all_pairs_node_connectivity` |
There was a problem hiding this comment.
By "functions like connectivity.all_pairs_node_connectivity," I meant those with a name parameter defined in the _dispatchable decorator. For example, approximate_all_pairs_node_connectivity is not the actual name of the function in the networkx but in the name parameter of the decorator-- because the name all_pairs_node_connectivity is already used by connectivity.all_pairs_node_connectivity. The current logic-- splitting on . -- works with existing functions, but i'm not sure if there's a consistent rule for setting the name parameter in networkx. It may be worth updating the code if there is a rule or adding a comment to clarify this for future reference/maintenance.
There was a problem hiding this comment.
Thank you! That makes sense — I’ll close this and keep it in mind to revisit when needed :)
|
No need to close this PR-- i hope the clarification in PR networkx/networkx#8168 helps and here we can simply use |
| def assign_algorithms(cls): | ||
| """Class decorator to assign algorithms to the class attributes.""" | ||
| for attr in ALGORITHMS: | ||
| # get the function name by parsing the module hierarchy | ||
| func_name = attr.rsplit(".", 1)[-1] | ||
| setattr(cls, func_name, attrgetter(attr)(algorithms)) | ||
| setattr(cls, attr, attrgetter(attr)(algorithms)) | ||
| return cls |
There was a problem hiding this comment.
For future reference-- since this decorator is only used on BackendInterface, it might be easier for future code-readers-- if we simply move this logic into the class or immediately after its definition. Not a blocker!
Schefflera-Arboricola
left a comment
There was a problem hiding this comment.
Thanks @akshitasure12 !
* clean up test_get_functions_with_get_chunks * change attr to algo for readability * remove module heirarchy * rm set() * added list() * reverting
* clean up test_get_functions_with_get_chunks * change attr to algo for readability * remove module heirarchy * rm set() * added list() * reverting
This PR refactors the
test_get_functions_with_get_chunkstest to dynamically use theALGORITHMSfrom interface.py instead of relying on a hardcoded expected set. It strips module prefixes for algorithms likeconnectivity.all_pairs_node_connectivity.