Skip to content

indexing test cleanup#4001

Open
d-v-b wants to merge 28 commits into
zarr-developers:mainfrom
d-v-b:indexing-test-cleanup
Open

indexing test cleanup#4001
d-v-b wants to merge 28 commits into
zarr-developers:mainfrom
d-v-b:indexing-test-cleanup

Conversation

@d-v-b
Copy link
Copy Markdown
Contributor

@d-v-b d-v-b commented May 22, 2026

This PR applies a cleanup to our test suite, with a particular focus on the array indexing tests. The goal is to make the tests run faster with fewer lines of code, without any loss in coverage.

d-v-b and others added 28 commits May 22, 2026 17:55
Plan to consolidate and speed up tests/test_indexing.py: shrink oversized
arrays (>=3 chunks/axis, partial edge), replace np.random selection loops
with hand-picked parametrized cases via the Expect/ExpectFail dataclasses,
one-behavior-per-test isolation, and docstrings throughout. Includes a
prerequisite step deduplicating the two divergent Expect dataclass pairs
(tests/conftest.py vs tests/test_codecs/conftest.py) onto one canonical pair.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Task-by-task plan: Expect dataclass dedup (Part 0) then per-family rewrites
of tests/test_indexing.py to parametrized Expect/ExpectFail cases on smaller
arrays (Part 1), with final verification and speed measurement (Part 2).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Prepares for deduplicating the second Expect pair in test_codecs/conftest.py.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
All consumers now use the canonical Expect/ExpectFail from tests/conftest.py.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Smaller array (30 elems, chunks of 7), hand-picked deterministic masks
replacing np.random sparsity sweep, error paths split into their own test.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Structural fix for the msg="" footgun discovered during Task 1.1: msg becomes
optional and regex-matched via a case.raises() helper, with an escape flag.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
msg defaults to None (assert exception type only) and is treated as a regex,
with an escape flag for literal messages. Removes the msg="" footgun that the
repo's filterwarnings=["error"] config turned into a failure.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
np.arange(30) == 7 reads better than np.eye(1, 30, 7)[0]; matters because the
other indexing families copy this exemplar.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Reuses the get-orthogonal case tables; deletes the per-dimensionality set
helpers.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The basic-selection rewrite dropped two assertions that get_basic_selection
rejects integer-list selections (1D direct, 2D nested in a tuple); restore
them as dedicated get-only tests, since z[...] falls back to fancy indexing.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
asyncio_mode = "auto" already collects async test functions; the explicit
marks were no-ops.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Rename XXXX.misc.md to the PR number when the PR is opened.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented May 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.49%. Comparing base (c0e2afa) to head (b4892af).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4001   +/-   ##
=======================================
  Coverage   93.49%   93.49%           
=======================================
  Files          88       88           
  Lines       11873    11873           
=======================================
  Hits        11101    11101           
  Misses        772      772           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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