Skip to content

Simplifications round 2: consolidate int dtype boilerplate, dedupe indexing/registry/store helpers - #193

Draft
d-v-b wants to merge 16 commits into
mainfrom
claude/simplifications-round2
Draft

d-v-b wants to merge 16 commits into
mainfrom
claude/simplifications-round2

Conversation

@d-v-b

@d-v-b d-v-b commented Jun 12, 2026 •

Copy link
Copy Markdown
Owner

🤖 AI text below 🤖

Consolidates integer dtype conversion and JSON handling in BaseInt, shares store/registry/indexing helpers, removes unused private helpers, and removes duplicate compressor parsing in Group.create_array.

The intended normal runtime outputs remain the same, but this is not literally a zero-API-change or byte-for-byte-error-message refactor: inherited integer conversion/serialization annotations are broader than the former subclass annotations, and invalid Buffer errors now use the concrete store class name, so subclasses can report a different prefix.

BasicIndexer and BlockIndexer share a loop that assembles chunk projections in one pass. This reduces repeated iteration in the implementation; no speedup is claimed without a benchmark. Int8/UInt8 retain their lack of meaningful byte order, and Int32/UInt32 keep their Windows-specific native dtype checks.

Earlier test totals in this PR's history are historical results, not a fresh validation of this head.

dependabot Bot and others added 15 commits May 31, 2026 19:28
…#176)

Bumps the actions group with 8 updates in the / directory:

| Package | From | To |
| --- | --- | --- |
| [prefix-dev/setup-pixi](https://github.com/prefix-dev/setup-pixi) | `0.9.5` | `0.9.6` |
| [codecov/codecov-action](https://github.com/codecov/codecov-action) | `6.0.0` | `6.0.1` |
| [github/issue-metrics](https://github.com/github/issue-metrics) | `4.2.2` | `4.2.7` |
| [j178/prek-action](https://github.com/j178/prek-action) | `2.0.3` | `2.0.4` |
| [actions/upload-artifact](https://github.com/actions/upload-artifact) | `7.0.0` | `7.0.1` |
| [actions/download-artifact](https://github.com/actions/download-artifact) | `7.0.0` | `8.0.1` |
| [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) | `1.13.0` | `1.14.0` |
| [zizmorcore/zizmor-action](https://github.com/zizmorcore/zizmor-action) | `0.5.3` | `0.5.6` |



Updates `prefix-dev/setup-pixi` from 0.9.5 to 0.9.6
- [Release notes](https://github.com/prefix-dev/setup-pixi/releases)
- [Commits](prefix-dev/setup-pixi@1b2de7f...5185adf)

Updates `codecov/codecov-action` from 6.0.0 to 6.0.1
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md)
- [Commits](codecov/codecov-action@57e3a13...e79a696)

Updates `github/issue-metrics` from 4.2.2 to 4.2.7
- [Release notes](https://github.com/github/issue-metrics/releases)
- [Commits](github-community-projects/issue-metrics@c9e9838...1e38d5e)

Updates `j178/prek-action` from 2.0.3 to 2.0.4
- [Release notes](https://github.com/j178/prek-action/releases)
- [Commits](j178/prek-action@6ad8027...bdca6f1)

Updates `actions/upload-artifact` from 7.0.0 to 7.0.1
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](actions/upload-artifact@v7...043fb46)

Updates `actions/download-artifact` from 7.0.0 to 8.0.1
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](actions/download-artifact@v7...3e5f45b)

Updates `pypa/gh-action-pypi-publish` from 1.13.0 to 1.14.0
- [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases)
- [Commits](pypa/gh-action-pypi-publish@v1.13.0...cef2210)

Updates `zizmorcore/zizmor-action` from 0.5.3 to 0.5.6
- [Release notes](https://github.com/zizmorcore/zizmor-action/releases)
- [Commits](zizmorcore/zizmor-action@b1d7e1f...5f14fd0)

---
updated-dependencies:
- dependency-name: prefix-dev/setup-pixi
  dependency-version: 0.9.6
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: actions
- dependency-name: codecov/codecov-action
  dependency-version: 6.0.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: actions
- dependency-name: github/issue-metrics
  dependency-version: 4.2.7
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: actions
- dependency-name: j178/prek-action
  dependency-version: 2.0.4
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: actions
- dependency-name: actions/upload-artifact
  dependency-version: 7.0.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: actions
- dependency-name: actions/download-artifact
  dependency-version: 8.0.1
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: actions
- dependency-name: pypa/gh-action-pypi-publish
  dependency-version: 1.14.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: actions
- dependency-name: zizmorcore/zizmor-action
  dependency-version: 0.5.6
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: actions
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Mirror the BaseFloat/BaseComplex pattern on BaseInt: define
from_native_dtype/to_native_dtype/_from_json_v2/_from_json_v3/to_json once
on the base, driven by the _zarr_v2_names/_zarr_v3_name class vars. The 8 int
subclasses shrink to their class vars plus the item_size property.

Endianness is the only real structural variation: Int8/UInt8 have no byte
order and do not mix in HasEndianness, so the shared native-dtype conversion
branches on isinstance(self, HasEndianness) / a _has_endianness flag (the flag
avoids mypy's issubclass intersection-narrowing at the base-class site). The
two Windows-specific _check_native_dtype overrides on Int32/UInt32 are kept.

Also removes the duplicate UInt64.from_native_dtype definition (B17, the
second shadowed the first) and a docstring typo.

No public-API or behavior change; tests/test_dtype pass identically
(960 passed, 8 skipped). int.py: 1551 -> 726 lines.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Group.create just forwards to Group.create_array with an identical signature.
Replace the ~120-line duplicated parameter docstring with a one-line alias
docstring linking to create_array. No code, signature, or behavior change.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The three _parse_bytes_bytes_codec / _parse_array_bytes_codec /
_parse_array_array_codec functions were structurally identical, differing only
in the codec class checked and the indefinite article in the error message.
Extract a generic _parse_codec[T: Codec](data, cls, article) -> T helper and
keep the three public names as thin wrappers (callers in array.py import them
by name). Error message text is preserved byte-for-byte.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…(S16)

Seven copies of the same "value must be a Buffer instance" TypeError guard
(across MemoryStore, GpuMemoryStore, LocalStore, FsspecStore, ZipStore) are
replaced by a single Store._check_value helper on the ABC. The store-name
prefix is derived from type(self).__name__, reproducing each store's message
byte-for-byte. Buffer imports that became annotation-only are moved into the
TYPE_CHECKING blocks.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…chers (S17)

_get_node_v2/_get_node_v3 differed only in which _read_metadata_v{2,3} they
called before delegating to _build_node; inline both into get_node. Likewise
_read_group_metadata_v2/_v3 shared an identical isinstance(GroupMetadata)
check and error message; inline both into _read_group_metadata. All four were
private and only called from their own dispatcher.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The four copies of the coordinate/mask vindex dispatch (VIndex.__getitem__,
VIndex.__setitem__, AsyncVIndex.getitem, get_indexer) each spelled out the
same 6-line "unsupported selection type for vectorized indexing" error in
their else branch. Extract a single _raise_vindex_invalid_selection(selection)
-> NoReturn helper; the is_coordinate_selection/is_mask_selection TypeGuard
dispatch (whose targets genuinely differ per call site) is left in place so
narrowing is preserved. Error message text is unchanged.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…20, P10)

BasicIndexer.__iter__ and BlockIndexer.__iter__ were byte-identical and built
the four ChunkProjection fields (chunk coords, chunk selection, out selection,
completeness) in four separate passes over each chunk's dim projections.
Extract a shared module-level _iter_chunk_projections helper that builds all
four in a single pass. OrthogonalIndexer.__iter__ has extra advanced-indexing
logic and differing field types, so it is left unchanged. Behavior identical;
tests/test_indexing.py passes (424 passed).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ck_msg (S19)

Both private/unexported helpers have zero callers across src/ and tests/
(verified by grep). Remove them and the now-unused Awaitable/Callable imports
in sync.py. collect_aiterator (public-but-undocumented, also zero callers) is
intentionally left in place as it is technically part of the public surface;
it is a candidate for future deprecation.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sync Group.create_array pre-parsed the deprecated `compressor` argument and
then forwarded only the parsed `compressors` to AsyncGroup.create_array, which
parsed again. Drop the sync-side pre-parse and forward `compressor` through so
the deprecation handling happens exactly once in the async path. Behavior is
unchanged: the deprecation warning still fires once, ValueError on conflicting
compressor/compressors still raised, and the v2 default-blosc path is
preserved (verified by tests/test_v2.py and a manual single-warning check).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant