fix: correct FRLM summary coverage percent#518
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes FRLM dataframe summary reporting by computing the exported “Coverage %” from covered_volume (instead of a non-existent key) and adds a regression assertion to ensure the summary percentage matches the ratio derived from the exported coverage dataframe.
Changes:
- Update FRLM
to_dataframes()to sumcovered_volumewhen computing coverage percentage. - Add a test assertion validating the exported summary “Coverage %” against
covered_volume / flow_volume.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
spopt/locate/flow.py |
Corrects the coverage-percent numerator to use covered_volume from flow_coverage. |
spopt/tests/test_locate/test_flow.py |
Adds a regression check ensuring the summary coverage percent matches the exported coverage dataframe totals. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| for coverage in self.flow_coverage.values() | ||
| ) | ||
| total_flow = sum(self.flows.values()) | ||
| coverage_pct = covered_flow_sum / total_flow * 100 |
There was a problem hiding this comment.
coverage_pct = covered_flow_sum / total_flow * 100 will raise ZeroDivisionError when flows are loaded but their total volume sums to 0 (allowed today since add_flow doesn’t validate volume > 0). Other parts of this module guard with if total_flow > 0 else 0 (e.g., _get_flow_details). Please add the same guard here so to_dataframes() can export summaries for zero-total-volume inputs without crashing.
| coverage_pct = covered_flow_sum / total_flow * 100 | |
| coverage_pct = covered_flow_sum / total_flow * 100 if total_flow > 0 else 0 |
This PR fixes FRLM dataframe summary reporting by calculating
Coverage %fromcovered_volumeinstead of a non-existent key, and adds a focused regression assertion that compares the exported summary percentage against the ratio derived from the coverage dataframe, ensuring the reported metric stays consistent with computed flow coverage values.