fix: ensure contiguous spans in span_range with exact=True and month frame (#1185) - #1332
Open
deepakganesh78 wants to merge 1 commit into
Open
Conversation
…frame When span_range iterates with frame='month' and exact=True, months with fewer days cause day clipping in range() (e.g. Jan 31 -> Feb 28). The subsequent span(exact=True) computes the ceiling from the clipped date, but range() restores the original day for the next iteration point, leaving a multi-day gap between consecutive spans. Fix: track the previous span's ceiling and use it (+1 µs) as the floor of the next span whenever the computed floor would leave a gap. Fixes arrow-py#1185 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1332 +/- ##
===========================================
- Coverage 100.00% 99.91% -0.09%
===========================================
Files 10 10
Lines 2315 2321 +6
Branches 358 360 +2
===========================================
+ Hits 2315 2319 +4
- Misses 0 1 +1
- Partials 0 1 +1 ☔ View full report in Codecov by Harness. |
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.
Fixes #1185
Problem
span_range('month', start, end, exact=True)produces gaps (missing days) when the start day exceeds the number of days in a shorter month. For example, starting on Jan 31:Root cause
range()clips the day when shifting into a shorter month (Jan 31 → Feb 28) and later restores it when months are long enough again (→ Mar 31). Eachspan(exact=True)computes a one-month window from its iteration point, so the clipped Feb 28 produces a ceiling of Mar 27, while the restored Mar 31 becomes the next floor — leaving a 3-day gap.Fix
Track the previous span's ceiling; when the next computed floor would leave a gap, substitute
prev_ceil + 1 µsas the floor instead, ensuring every moment betweenstartandendis covered by exactly one span.Validation
test_exact_month_no_gaps_when_day_clippedaddedCo-authored-by: Copilot 223556219+Copilot@users.noreply.github.com