Repository navigation
Add feature to make storing node contraction data optional - #7902
Merged
Merged
Conversation
dschult
reviewed
Mar 12, 2025
dschult
left a comment
Member
There was a problem hiding this comment.
Thanks for this! Looks good!
Yes -- let's make the kwarg provide an attribute name to store the contraction data. If it is None or False then don't store any data. (Or if there is a better way that's fine too.) The fixed attribute name would be good to make flexible.
I like the refactor of the tests. It's easier to read IMO.
Co-authored-by: Dan Schult <[email protected]>
Contributor
|
I fixed the tests by updating some of the dispatch testing code. There is a bit of technical debt here, so there ought to be a better way to address issues like this if I'm not around. |
Contributor
Author
|
Okay, two major changes since the last round of review:
|
This was referenced Apr 16, 2025
eriknw
approved these changes
Apr 21, 2025
Co-authored-by: Erik Welch <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements the feature discussed in #7781 - adds a
store_contractionkwarg tocontracted_nodesto allow the user to specify whether to store info about the contraction as node/edge attributes on the resulting graph.The feature was relatively straightforward to implement - unfortunately the diff is kind of intimidating due to all the test suite changes. Despite the removals in the test suite, all changes are about beefing up the existing tests; particularly parametrizing over the boolean flags that already exist (
self_loopsandcopy). However, I know how much I personally dislike changes to the test suite when reviewing, so I'm happy to split this up into two PRs where one covers the changes to the existing tests (without thestore_contractionfeature), and a second which simply adds the coverage related tostore_contraction.Finally, I there's likely an API discussion to be had here. I went with a boolean flag to indicate whether to store data, but hard-coding attribute names is not very networkx-y. We could also take this opportunity to do something similar to the layouts, i.e. add
store_contraction_as="contraction". Happy to do so here or in follow-up PRs - LMK what you think! Either way, the addition will be backward-compatible!