Skip to content

Commit

Permalink
Automagic dispatch for universal functions (#883)
Browse files Browse the repository at this point in the history
Follow up of #882, albeit more agressive on shortening the boilerplate amount of code for universal functions

This PR introduces a new _rustworkx_dispatch decorator that:

* Creates the singledispatch for func
* Automatically registers digraph_func for PyDiGraph
* Automatically registers graph_func for PyGraph

The decorator is based on the original functools.singledispatch. It should simplify the amount of code we need to write an universal function. It does add a little bit of "magic" with functools and importlib, but overall it should be maintainable

* Try to shorten Bellman-Ford

* More shortening

* Even more

* Almost done with shortening

* Finish shortening

* Fix layout incorrect default arguments

* Simplify distance_matrix

* Magic custom dispatcher

* Minor detail about is_isomorphic_node_match

* Black

* Use explicit package name

* Minor change

* Sync with main

* Black

* Minor fix

* Sync with new functions

* Synch with new functions

* Fix cargo lock

* Cargo.lock strikes again

* Fix black error

* Black fmt

* Do not explicitly export rustworkx_dispatch
  • Loading branch information
IvanIsCoding authored Feb 22, 2024
1 parent bf3f703 commit f3cc7fd
Showing 1 changed file with 66 additions and 269 deletions.
Loading

0 comments on commit f3cc7fd

Please sign in to comment.