Skip to content

Fix time groups at calendar boundaries with group_time_by - #435

Merged
damianooldoni merged 2 commits into
inbo:mainfrom
northfox:fix/433-group-time-by-boundaries
Oct 7, 2026
Merged

damianooldoni merged 2 commits into
inbo:mainfrom
northfox:fix/433-group-time-by-boundaries

Conversation

@northfox

Copy link
Copy Markdown
Collaborator

Fixes #433.

  • create_date_series(): build the time groups from one sequence of calendar boundaries, so deployments starting or ending on a boundary get correct effort. A zero-length deployment on a boundary still returns one time group with zero effort.
  • enrich_observations(): replace the between() join with a rolling join, so observations are assigned to half-open time groups [start, next start) and an observation on a boundary is counted once. The last time group also includes its end, so an observation at deploymentEnd stays in it.
  • Added tests (fail on main, pass here) and a NEWS.md entry.

In the GMU8_Leuven example from #433, group_time_by = "day" now gives 483 observations, the same as without time grouping (previously 502).

Derive the start and end of the time groups in `create_date_series()` from
one sequence of calendar boundaries, so deployments starting or ending on a
boundary get correct time groups and effort. A deployment of zero duration
on a boundary still returns one time group with zero effort.

Match observations to the time group starting at or before `eventStart` in
`enrich_observations()`, so an observation on a boundary is counted once.

Fixes inbo#433
@damianooldoni
damianooldoni self-requested a review October 7, 2026 11:57

@damianooldoni damianooldoni left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @northfox for solving also this issue! The solution works well and doesn't add any complexity, on the contrary!

@damianooldoni damianooldoni self-assigned this Oct 7, 2026
@damianooldoni
damianooldoni merged commit 9f64280 into inbo:main Oct 7, 2026
10 checks passed
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.

summarize_deployments() / summarize_observations() mishandle timestamps on group_time_by boundaries

2 participants