-
Notifications
You must be signed in to change notification settings - Fork 200
Bugfix/json preserves node gaps #1517
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bugfix/json preserves node gaps #1517
Conversation
Pull Request Test Coverage Report for Build 21502772359Details
💛 - Coveralls |
|
I will take a look at this during the weekend. Thanks for sending the fix for an issue you found! |
IvanIsCoding
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent test cases! I have no doubt this works, I just left some comments on what should be improved in Rust.
src/json/node_link_data.rs
Outdated
|
|
||
| id_mapping.insert(node_id, idx); | ||
| // Mark this index as used (remove from tmp_nodes) | ||
| tmp_nodes.retain(|&n| n != idx); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can lead to quadratic behaviour, we are looping through all tmp_nodes to delete the index.
Please use https://docs.rs/hashbrown/latest/hashbrown/struct.HashSet.html instead
tests/graph/test_pickle.py
Outdated
| self.assertEqual(g.node_indices(), gprime.node_indices()) | ||
| self.assertEqual(g.edge_list(), gprime.edge_list()) | ||
| self.assertEqual(g.nodes(), gprime.nodes()) | ||
| self.assertEqual(dict(g.edge_index_map()), dict(gprime.edge_index_map())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Of course you copied examples that don't use it but: https://docs.python.org/3/library/unittest.html#unittest.TestCase.assertDictEqual
This just has a nicer error message, in case someone ever introduces a bug
|
Also, you'll need to solve some minor conflicts with #1510 |
Addresses #1516: JSON roundtrip is broken whenever the graph contains deleted (or contracted) nodes.
This leaves just the GraphML format as incapable of a clean round-trip.