Add set_branch_orientations utility function#156
Conversation
Signed-off-by: Thijs Baaijen <13253091+Thijss@users.noreply.github.com>
Signed-off-by: Thijs Baaijen <13253091+Thijss@users.noreply.github.com>
Signed-off-by: Thijs Baaijen <13253091+Thijss@users.noreply.github.com>
…tests Signed-off-by: Thijs Baaijen <13253091+Thijss@users.noreply.github.com>
… source connection issues Signed-off-by: Thijs Baaijen <13253091+Thijss@users.noreply.github.com>
Signed-off-by: Thijs Baaijen <13253091+Thijss@users.noreply.github.com>
Signed-off-by: Thijs Baaijen <13253091+Thijss@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR adds a new utility function fix_branch_orientations() to automatically orient all branches in a grid away from source nodes. The function ensures that in a radial network topology, all branches flow outward from the sources, which is important for power flow calculations and network analysis.
Changes:
- Added
fix_branch_orientations()utility function that reorients branches to flow away from sources - Added
has_parallel_edges()method to the graph model interface to detect parallel edges - Added comprehensive test coverage for both new features
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/power_grid_model_ds/utils.py | New file containing the fix_branch_orientations() function and helper functions for branch orientation fixing |
| src/power_grid_model_ds/_core/model/graphs/models/base.py | Added abstract method has_parallel_edges() to the base graph model interface |
| src/power_grid_model_ds/_core/model/graphs/models/rustworkx.py | Implemented has_parallel_edges() by delegating to rustworkx's built-in method |
| tests/unit/test_utils.py | New test file with comprehensive tests for fix_branch_orientations() covering basic functionality, dry-run mode, cycle detection, connected sources, and parallel edges |
| tests/unit/model/graphs/test_graph_model.py | Added tests for has_parallel_edges() method, including both same-direction and reversed parallel edges |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Thijs Baaijen <13253091+Thijss@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Thijs Baaijen <13253091+Thijss@users.noreply.github.com>
Signed-off-by: Thijs Baaijen <13253091+Thijss@users.noreply.github.com>
Signed-off-by: Thijs Baaijen <13253091+Thijss@users.noreply.github.com>
jaapschoutenalliander
left a comment
There was a problem hiding this comment.
I have some input on the setup but overall it looks good and I think it is a useful util function
Signed-off-by: Thijs Baaijen <13253091+Thijss@users.noreply.github.com>
Signed-off-by: Thijs Baaijen <13253091+Thijss@users.noreply.github.com>
Signed-off-by: Thijs Baaijen <13253091+Thijss@users.noreply.github.com>
vincentkoppen
left a comment
There was a problem hiding this comment.
Looks good!
Some remarks, but nice functionality to add :)
Signed-off-by: Thijs Baaijen <13253091+Thijss@users.noreply.github.com>
Signed-off-by: Thijs Baaijen <13253091+Thijss@users.noreply.github.com>
Signed-off-by: Thijs Baaijen <13253091+Thijss@users.noreply.github.com>
Signed-off-by: Thijs Baaijen <13253091+Thijss@users.noreply.github.com>
Signed-off-by: Thijs Baaijen <13253091+Thijss@users.noreply.github.com>
Signed-off-by: Thijs Baaijen <13253091+Thijss@users.noreply.github.com>
Signed-off-by: Thijs Baaijen <13253091+Thijss@users.noreply.github.com>
Signed-off-by: Thijs Baaijen <13253091+Thijss@users.noreply.github.com>
Co-authored-by: Vincent Koppen <53343926+vincentkoppen@users.noreply.github.com> Signed-off-by: Thijs Baaijen <13253091+Thijss@users.noreply.github.com>
Signed-off-by: Thijs Baaijen <13253091+Thijss@users.noreply.github.com>
Signed-off-by: Thijs Baaijen <13253091+Thijss@users.noreply.github.com>
Signed-off-by: Thijs Baaijen <13253091+Thijss@users.noreply.github.com>
|



Adds two new Grid functions:
Todo
Piggyback
BaseGraph.has_parallel_edges()Performance
I did some testing on our production data