Repository navigation
refactor: simplify k_factor - #8139
Conversation
rossbar
left a comment
There was a problem hiding this comment.
As a general comment - when making PRs that change both the code and the related tests, I would vastly prefer if the test changes and code changes were at least split into separate PRs. One of the main purposes of the test suite is to guarantee that the existing behavior is preserved under the new changes in the code. When both are changed simultaneously, this is no longer possible... at least not without significant overhead of checking out old tests from other branches locally etc.
951a82a to
40249aa
Compare
|
@rossbar Your comment makes a lot of sense! I've rebased to get rid of the test-related changes, and will open a separate PR for those. |
rossbar
left a comment
There was a problem hiding this comment.
Thanks @Peiffap , getting rid of the KGadget classes is certainly a readability improvement IMO. So much so that I have trouble using the original implementation as a reference.
Generally I think things are consistent but this should definitely have another set of eyes, particularly if anyone is familiar with k-factors!
I left one additional comment near the end about designing a test to probe a specific set of lines, but that's not a blocker to this PR for me. Thanks @Peiffap !
Co-authored-by: Ross Barnowski <[email protected]>
|
I added some benchmarks too. We're roughly in the same ballpark as before (which shouldn't be surprising as the underlying algorithm hasn't changed). |
464ff01 to
ad0189f
Compare
ad0189f to
5817a5c
Compare
| matching_weight: string, optional (default="weight") | ||
| Edge data key corresponding to the edge weight. | ||
| Used for finding the max-weighted perfect matching. | ||
| If the key is not found, all edges are considered to have the same weight. |
There was a problem hiding this comment.
This changed line is confusing to me. How can a missing edge key on one edge mean that all edges will have the edge weights ignored. I know this change is intended to be mostly about indentation. But sneaking in a few wording changes makes it hard to tell what was changed here. Can we leave the wording the same?
Or change the wording to our typical ("node" instead of "vertex", "edge attribute name" instead of "edge data key", "is not present" instead of "not found")
There was a problem hiding this comment.
I've update the wording to match the rest of the codebase, and reverted the previous change (which was wrong). Thanks for catching this; It wasn't my intention to do anything sneaky here! :)
Co-authored-by: Dan Schult <[email protected]>
This PR simplifies the
k_factorfunction by removing the largely redundant classes for gadgets. I've also cleaned up the docstring a little bitand made the test suite more comprehensive.Since this function returns a graph, should it also be renamed to include the
_graphsuffix?