Add network statistics workflow step#80
Merged
networmix merged 2 commits intocapacity_analysisfrom Jul 5, 2025
Merged
Conversation
There was a problem hiding this comment.
Pull Request Overview
Adds a new NetworkStats workflow step that computes basic capacity and degree statistics for network links and nodes, along with tests and documentation updates.
- Implemented and registered the
NetworkStatsstep in the workflow package. - Added a unit test to verify link and per-node statistics.
- Updated DSL, CLI, and API reference docs to include the new step.
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| ngraph/workflow/network_stats.py | Implements the NetworkStats step and registers it. |
| ngraph/workflow/init.py | Exports NetworkStats in the workflow package. |
| tests/workflow/test_network_stats.py | Adds unit test for the new workflow step. |
| docs/reference/dsl.md | Documents NetworkStats in the DSL reference. |
| docs/reference/cli.md | Adds NetworkStats to CLI output documentation. |
| docs/reference/api.md | Includes NetworkStats in the API reference list. |
| docs/reference/api-full.md | Provides full API docs for NetworkStats. |
Comments suppressed due to low confidence (2)
tests/workflow/test_network_stats.py:52
- This test validates link and per-node stats but does not assert on
node_capacityandnode_degreedistributions. Consider adding assertions for those keys to ensure full coverage of the new workflow step.
assert set(per_node.keys()) == {"A", "B", "C"}
docs/reference/api.md:201
- The
NetworkStatsentry appears to be commented out; remove the leading#so it renders properly in the list of available workflow steps.
# - NetworkStats: Computes basic capacity and degree statistics
Comment on lines
+31
to
+38
| link_caps_sorted = sorted(link_caps) | ||
| link_stats = { | ||
| "values": link_caps_sorted, | ||
| "min": min(link_caps_sorted) if link_caps_sorted else 0.0, | ||
| "max": max(link_caps_sorted) if link_caps_sorted else 0.0, | ||
| "mean": mean(link_caps_sorted) if link_caps_sorted else 0.0, | ||
| "median": median(link_caps_sorted) if link_caps_sorted else 0.0, | ||
| } |
There was a problem hiding this comment.
The logic for building distribution stats is duplicated for links, node capacities, and node degrees. Consider extracting this into a helper function to reduce repetition and improve readability.
Suggested change
| link_caps_sorted = sorted(link_caps) | |
| link_stats = { | |
| "values": link_caps_sorted, | |
| "min": min(link_caps_sorted) if link_caps_sorted else 0.0, | |
| "max": max(link_caps_sorted) if link_caps_sorted else 0.0, | |
| "mean": mean(link_caps_sorted) if link_caps_sorted else 0.0, | |
| "median": median(link_caps_sorted) if link_caps_sorted else 0.0, | |
| } | |
| link_stats = self.compute_distribution_stats(link_caps) |
… of disabled nodes and links in statistics. Update related logic and tests to ensure backward compatibility and correct behavior.
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.
Summary
NetworkStatsworkflow step to compute base capacity and degree statsNetworkStatsfrom workflow packageTesting
make formatmake check