Skip to content

Cover the CoordRange fast paths missed on dev - #790

Merged
d-chambers merged 3 commits into
devfrom
coords-coverage-gaps
Jul 27, 2026
Merged

Cover the CoordRange fast paths missed on dev#790
d-chambers merged 3 commits into
devfrom
coords-coverage-gaps

Conversation

@d-chambers

@d-chambers d-chambers commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Description

Restores 100% coverage on dev. The perf work in #778 left two uncovered lines in dascore/core/coords.py, which every branch cut since then inherits (#784 and #786 both report the same two misses).

_round_ratio ndarray branch (validator) — dead code. Multi-element arrays never reach it: validate_start_stop_step_len calls pd.isnull on start/stop/step/shape first, which raises on any array with more than one element. Only scalars, 0d arrays, and 1-element arrays (unboxed by _maybe_unbox_scalar) get that far, and float() handles all of them. Removed, with a test for the 0d-array input that used to take that branch.

Non-finite fraction guard in CoordRange._get_index — only reachable for a CoordRange with a step of 0 (test_coord_range_len_1 covers building one), and nothing selected on one. Doing so turned up two problems:

  • The scalar fast path added in PERF: speed up hot metadata paths in coords, units, and time utils #778 divides python scalars directly, so CoordRange(start=0, stop=0, step=0).select((0, 10)) raised ZeroDivisionError. Numpy scalars instead give inf/nan and hit the guard. Both are now handled.
  • The old behavior was not worth restoring. Every sample of a zero-step coord equals start (.values is [start]), but on dev/master select((0, 0)) returned an empty coord while select((1, None)) kept the sample — an artifact of inf/nan casting to INT64_MIN, not a contract. _get_zero_step_index now gives these coords real single-value semantics: bounds containing start keep the sample, bounds that don't select nothing.

The zero step is detected after the division rather than up front because testing a numpy step for truthiness costs ~130 ns for timedelta64 vs ~12 ns for math.isfinite, and this is a hot path for time-coordinate selection.

Also marks the three thread-spawning tests added in #781 (TestRemoteCacheConcurrency and TestIOResourceManagerConcurrency in tests/test_utils/test_io_utils.py) with concurrency, which they were missing. They fail with RuntimeError: can't start new thread in the WebAssembly suite added by #783, which deselects not network and not concurrency. An AST sweep over tests/ confirms these were the only thread-using tests without the mark.

Changelog

none

Checklist

I have (if applicable):

  • referenced the GitHub issue this PR closes.
  • documented the new feature with docstrings and/or appropriate doc page.
  • included tests. See testing guidelines.
  • added the "ready_for_review" tag once the PR is ready to be reviewed.

@d-chambers d-chambers added the ready_for_review PR is ready for review label Jul 26, 2026
@coderabbitai

coderabbitai Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@d-chambers, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 43 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a063d7c6-295b-47bc-a84b-0fc77f6e05cd

📥 Commits

Reviewing files that changed from the base of the PR and between 076e049 and 6cf424b.

📒 Files selected for processing (3)
  • dascore/core/coords.py
  • tests/test_core/test_coords.py
  • tests/test_utils/test_io_utils.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch coords-coverage-gaps

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5999495d2a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread dascore/core/coords.py Outdated
Comment on lines +1539 to +1540
except ZeroDivisionError:
return None

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Reject disjoint selections on zero-step ranges

When a length-one range has a Python-scalar zero step, returning None here treats every finite bound as unconstrained, so CoordRange(start=0, stop=0, step=0).select((1, 10)) silently returns the value at 0 rather than an empty coordinate; half-bounded selections such as (1, None) fail similarly. Handle the zero-step case by comparing the bound with the singleton value, and add disjoint-boundary coverage rather than testing only a range containing start. .agents/agents.mdL66-L72

Useful? React with 👍 / 👎.

The perf work in #778 left two lines uncovered in dascore/core/coords.py:

- the ndarray branch of _round_ratio in the CoordRange validator, which is
  dead code (multi-element arrays are rejected earlier by the pd.isnull
  check, so the ratio is always scalar-like); it is removed.
- the guard returning None when the index fraction isn't finite, i.e. a
  CoordRange with a step of 0. Selecting on such a coord with python (not
  numpy) scalars raised ZeroDivisionError rather than returning everything,
  which the array-based implementation prior to #778 did; that is fixed and
  both cases are now tested.
Every sample of such a coord equals start, so bounds which don't contain
start now yield a degenerate selection instead of keeping the sample.
They spawn threads via run_in_threads, which fails in WebAssembly where
the wasm suite deselects concurrency tests.
@d-chambers
d-chambers force-pushed the coords-coverage-gaps branch from a500983 to 6cf424b Compare July 26, 2026 18:43
@codecov

codecov Bot commented Jul 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (076e049) to head (6cf424b).

Additional details and impacted files
@@             Coverage Diff             @@
##              dev      #790      +/-   ##
===========================================
+ Coverage   99.98%   100.00%   +0.01%     
===========================================
  Files         164       164              
  Lines       17707     17713       +6     
===========================================
+ Hits        17705     17713       +8     
+ Misses          2         0       -2     
Flag Coverage Δ
network 48.20% <9.09%> (-0.02%) ⬇️
unittests 100.00% <100.00%> (+0.01%) ⬆️

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.

@d-chambers
d-chambers merged commit 023f066 into dev Jul 27, 2026
29 checks passed
@d-chambers
d-chambers deleted the coords-coverage-gaps branch July 27, 2026 03:34
@d-chambers d-chambers removed the ready_for_review PR is ready for review label Aug 11, 2026
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