fix: preserve graph types and metadata in sorting and splitting utilities#116
Open
AdMub wants to merge 2 commits intomllam:mainfrom
Open
fix: preserve graph types and metadata in sorting and splitting utilities#116AdMub wants to merge 2 commits intomllam:mainfrom
AdMub wants to merge 2 commits intomllam:mainfrom
Conversation
73c2ae6 to
ce4509f
Compare
Contributor
Author
|
Hi @mllam, I've resolved the linting failures and all CI checks are now passing. This fix ensures that graph-level metadata (like CRS) is preserved during sorting and splitting. Ready for your feedback! |
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.
Describe your changes
This PR fixes a silent data-loss bug in the core
networkx_utilsfunctions:sort_nodes_internallyandsort_nodes_in_graph.Previously, these functions hardcoded the output as a standard
networkx.DiGraph(). This meant that if a user passed in a different graph type (e.g., an undirectedGraphor aMultiDiGraph), or if the graph contained critical global metadata (such as coordinate reference systemsgraph['crs']or mesh spacinggraph['dx']), that data was completely stripped and lost during the sort operation.Changes:
networkx.DiGraph()with dynamic typing (type(graph)()) to preserve the original graph's class.graph.update(input.graph)to ensure all top-level graph attributes are safely carried over to the newly returned graphs.Issue Link
N/A - This addresses a silent bug found during codebase review.
Type of change
Checklist before requesting a review
pullwith--rebaseoption if possible).Checklist for reviewers
Each PR comes with its own improvements and flaws. The reviewer should check the following:
Author checklist after completed review
reflecting type of change (add section where missing):
Checklist for assignee