Skip to content

fix: compute SampledCoordinate._slice segment bounds from stop directly - #95

Merged
atrabattoni merged 1 commit into
xdas-dev:mainfrom
chenyangsu:fix/sampled-coordinate-slice-step
Dec 1, 2026
Merged

atrabattoni merged 1 commit into
xdas-dev:mainfrom
chenyangsu:fix/sampled-coordinate-slice-step

Conversation

@chenyangsu

Copy link
Copy Markdown
Contributor

On a 10-sample SampledCoordinate, coord[0:10:3] returns [0., 3., 6.] and coord[2:8:3] returns [2., 5., 8.] because _slice adds the divmod remainder r to each segment upper bound hi. Slicing a DataArray with da.isel(time=slice(0, 10, 3)) then raises a coordinate size mismatch.

Could we compute hi directly as np.minimum(stop - self.tie_indices, self.tie_lengths) and use (hi - lo + step - 1) // step for tie_lengths? Happy to drop the changelog line if you prefer updating it at release time.

Testing: pytest tests/coordinates/test_sampled.py -> 100 passed (2 new tests fail on main), ruff check and ruff format --check clean.

@codecov

codecov Bot commented Dec 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (8235e3e) to head (f81203b).

Additional details and impacted files
@@            Coverage Diff            @@
##              main       #95   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           49        49           
  Lines         9432      9430    -2     
  Branches      1701      1701           
=========================================
- Hits          9432      9430    -2     

☔ 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.

@atrabattoni atrabattoni self-assigned this Dec 1, 2026
@atrabattoni atrabattoni added the bug Something isn't working label Dec 1, 2026
@atrabattoni
atrabattoni self-requested a review December 1, 2026 14:58

@atrabattoni atrabattoni left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hello @chenyangsu ,

Thank you for reporting AND fixing this bug. It looks good to me so I merge it right away.

@atrabattoni
atrabattoni merged commit d9c9267 into xdas-dev:main Dec 1, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants