Skip to content

Improve time gap error messages with diagnostic detail#551

Merged
rbeucher merged 2 commits into
mainfrom
improve-time-gap-error-messages
Jul 23, 2026
Merged

Improve time gap error messages with diagnostic detail#551
rbeucher merged 2 commits into
mainfrom
improve-time-gap-error-messages

Conversation

@rbeucher

Copy link
Copy Markdown
Member

Summary

When time bounds continuity checks fail, the error message previously gave no indication of where in the time axis the problem was.

Before

ValueError: Time bounds are not contiguous. Missing or overlapping timesteps detected in the CMOR time axis.

After

ValueError: Time bounds are not contiguous. Missing or overlapping timesteps detected in the CMOR time axis.
  1 discontinuity(ies) found:
  [index 11→12] time 1990-11-16 → 1991-01-16: bound end=1990-12-01, next bound start=1991-01-01

For the frequency-fallback path, intervals now show the surrounding timestamps instead of just the day counts:

ValueError: Missing timesteps detected in time coordinate for expected 'monthly' cadence.
Invalid interval(s) (1 total): 1990-11-16 → 1991-01-16 (61.00 days)

Changes

  • Add _describe_bounds_gaps() static helper that identifies discontinuous bound indices and formats them with surrounding time coordinate values (up to 5 shown)
  • _time_bounds_have_gaps() interface unchanged — existing tests unaffected
  • Frequency-fallback gap list is now tuples of (t_before, t_after, delta_days) so timestamps appear in the error message

When time bounds are not contiguous, include the index, surrounding
timestamps, and mismatched bound values (up to 5 examples) so the
source of the gap is immediately visible in the error output.

For frequency-fallback gaps, show the actual timestamps bracketing
each invalid interval instead of just the day-length numbers.

Adds _describe_bounds_gaps() static helper; _time_bounds_have_gaps()
interface is unchanged (tests unaffected).
@codecov

codecov Bot commented Jul 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.75758% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.8%. Comparing base (d0815eb) to head (c0e2ffa).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
src/access_moppy/base.py 75.8% 5 Missing and 3 partials ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##            main    #551     +/-   ##
=======================================
- Coverage   74.9%   74.8%   -0.0%     
=======================================
  Files         36      36             
  Lines       7156    7191     +35     
  Branches    1333    1340      +7     
=======================================
+ Hits        5357    5381     +24     
- Misses      1519    1525      +6     
- Partials     280     285      +5     
Flag Coverage Δ
unit 74.8% <75.8%> (-<0.1%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@rbeucher
rbeucher merged commit e79ed99 into main Jul 23, 2026
3 of 4 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.

1 participant