Skip to content

fix: correct FRLM summary coverage percent#518

Open
samay2504 wants to merge 1 commit intopysal:mainfrom
samay2504:fix/frlm-dataframe-coverage
Open

fix: correct FRLM summary coverage percent#518
samay2504 wants to merge 1 commit intopysal:mainfrom
samay2504:fix/frlm-dataframe-coverage

Conversation

@samay2504
Copy link
Copy Markdown

This PR fixes FRLM dataframe summary reporting by calculating Coverage % from covered_volume instead 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.

Copilot AI review requested due to automatic review settings April 11, 2026 17:00
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 sum covered_volume when 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
Copy link

Copilot AI Apr 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
coverage_pct = covered_flow_sum / total_flow * 100
coverage_pct = covered_flow_sum / total_flow * 100 if total_flow > 0 else 0

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants