Skip to content

Commit 9c227df

Browse files
committed
minor improvements for analysis and reporting code
1 parent 19b5665 commit 9c227df

File tree

5 files changed

+32
-18
lines changed

5 files changed

+32
-18
lines changed

docs/reference/api-full.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ For a curated, example-driven API guide, see **[api.md](api.md)**.
1010
> - **[CLI Reference](cli.md)** - Command-line interface
1111
> - **[DSL Reference](dsl.md)** - YAML syntax guide
1212
13-
**Generated from source code on:** July 26, 2025 at 15:00 UTC
13+
**Generated from source code on:** July 27, 2025 at 07:33 UTC
1414

1515
**Modules auto-discovered:** 51
1616

ngraph/workflow/analysis/capacity_matrix.py

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import importlib
1010
from typing import Any, Dict, List, Optional
1111

12+
import matplotlib.pyplot as plt
1213
import pandas as pd
1314

1415
from .base import NotebookAnalyzer
@@ -412,9 +413,13 @@ def analyze_and_display_flow_availability(
412413
f" Median Flow: {stats['median_flow']:.2f} ({stats['flow_percentiles']['p50']['relative']:.1f}%)"
413414
)
414415
print(
415-
f" Std Dev: {stats['flow_std']:.2f} ({stats['relative_std']:.1f}%)"
416+
f" Std Dev: {stats['flow_std']:.2f} ({stats['relative_std']:.1f}%) "
417+
f"→ Flow dispersion magnitude relative to mean"
418+
)
419+
print(
420+
f" CV: {stats['coefficient_of_variation']:.1f}% "
421+
f"→ Normalized variability metric: <30% stable, >50% high variance\n"
416422
)
417-
print(f" CV: {stats['coefficient_of_variation']:.1f}%\n")
418423

419424
print("📈 Flow Distribution Percentiles:")
420425
for p_name in ["p5", "p10", "p25", "p50", "p75", "p90", "p95", "p99"]:
@@ -427,22 +432,33 @@ def analyze_and_display_flow_availability(
427432
print()
428433

429434
print("🎯 Network Reliability Analysis:")
430-
for reliability in ["99%", "95%", "90%", "80%"]:
435+
for reliability in ["99.99%", "99.9%", "99%", "95%", "90%", "80%"]:
431436
flow_fraction = viz_data["reliability_thresholds"].get(reliability, 0)
432437
flow_pct = flow_fraction * 100
433438
print(f" {reliability} reliability: ≥{flow_pct:5.1f}% of maximum flow")
434439
print()
435440

436441
print("📐 Distribution Characteristics:")
437442
dist_metrics = viz_data["distribution_metrics"]
438-
print(f" Gini Coefficient: {dist_metrics['gini_coefficient']:.3f}")
439-
print(f" Quartile Coefficient: {dist_metrics['quartile_coefficient']:.3f}")
440-
print(f" Range Ratio: {dist_metrics['flow_range_ratio']:.3f}\n")
443+
gini = dist_metrics["gini_coefficient"]
444+
quartile = dist_metrics["quartile_coefficient"]
445+
range_ratio = dist_metrics["flow_range_ratio"]
441446

442-
# Try to render plots (optional)
443-
try:
444-
import matplotlib.pyplot as plt
447+
print(
448+
f" Gini Coefficient: {gini:.3f} "
449+
f"→ Flow inequality: 0=uniform, 1=maximum inequality"
450+
)
451+
print(
452+
f" Quartile Coefficient: {quartile:.3f} "
453+
f"→ Interquartile spread: (Q3-Q1)/(Q3+Q1), measures distribution skew"
454+
)
455+
print(
456+
f" Range Ratio: {range_ratio:.3f} "
457+
f"→ Total variation span: (max-min)/max, failure impact magnitude\n"
458+
)
445459

460+
# Render plots for flow availability analysis
461+
try:
446462
cdf_data = viz_data["cdf_data"]
447463
percentile_data = viz_data["percentile_data"]
448464
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(14, 6))
@@ -476,8 +492,6 @@ def analyze_and_display_flow_availability(
476492

477493
plt.tight_layout()
478494
plt.show()
479-
except ImportError:
480-
print("Matplotlib not available for visualisation")
481495
except Exception as exc: # pragma: no cover
482496
print(f"⚠️ Visualisation error: {exc}")
483497

@@ -689,7 +703,7 @@ def _prepare_flow_cdf_visualization_data(
689703
percentiles.append(avail_prob)
690704
flow_at_percentiles.append(rel_flow)
691705

692-
reliability_thresholds = [99, 95, 90, 80, 70, 50]
706+
reliability_thresholds = [99.99, 99.9, 99, 95, 90, 80, 70, 50]
693707
threshold_flows: Dict[str, float] = {}
694708
for threshold in reliability_thresholds:
695709
target_avail = threshold / 100

ngraph/workflow/analysis/flow_analyzer.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import importlib
99
from typing import Any, Dict
1010

11+
import matplotlib.pyplot as plt
1112
import pandas as pd
1213

1314
from .base import NotebookAnalyzer
@@ -122,8 +123,6 @@ def display_analysis(self, analysis: Dict[str, Any], **kwargs) -> None:
122123
viz_data = analysis["visualization_data"]
123124
if viz_data["has_multiple_steps"]:
124125
try:
125-
import matplotlib.pyplot as plt
126-
127126
fig, ax = plt.subplots(figsize=(12, 6))
128127

129128
for step in viz_data["steps"]:
@@ -140,8 +139,8 @@ def display_analysis(self, analysis: Dict[str, Any], **kwargs) -> None:
140139
ax.legend()
141140
plt.tight_layout()
142141
plt.show()
143-
except ImportError:
144-
print("Matplotlib not available for visualization")
142+
except Exception as exc: # pragma: no cover
143+
print(f"⚠️ Visualization error: {exc}")
145144

146145
def analyze_capacity_probe(self, results: Dict[str, Any], **kwargs) -> None:
147146
"""Analyze and display capacity probe results for a specific step.

ngraph/workflow/analysis/package_manager.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ def setup_environment(cls) -> Dict[str, Any]:
6969
itables_opt.lengthMenu = [10, 25, 50, 100, 500, -1]
7070
itables_opt.maxBytes = 10**7 # 10MB limit
7171
itables_opt.maxColumns = 200 # Allow more columns
72+
itables_opt.showIndex = True # Always show DataFrame index as a column
7273

7374
# Configure warnings
7475
import warnings

tests/integration/test_scenario_4.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
- Bracket expansion in group names for multiple pattern matching
88
- Complex node and link override patterns with advanced regex
99
- Risk groups with hierarchical structure and failure simulation
10-
- Advanced workflow steps (EnableNodes, DistributeExternalConnectivity, NotebookExport)
10+
- Advanced workflow steps (EnableNodes, DistributeExternalConnectivity)
1111
- NetworkExplorer integration for hierarchy analysis
1212
- Large-scale network topology with realistic data center structure
1313

0 commit comments

Comments
 (0)