Skip to content

feat: implement the reshape extension codec - #4542

Open
clbarnes wants to merge 9 commits into
zarr-developers:mainfrom
clbarnes:reshape
Open

clbarnes wants to merge 9 commits into
zarr-developers:mainfrom
clbarnes:reshape

Conversation

@clbarnes

@clbarnes clbarnes commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Resolves #4541 .

Implements the reshape extension codec.
This codec was recommended for inclusion in mainline zarr-python because it will be built on top of by other codecs (e.g. most image codecs).

Author attestation

  • I am a human, these are my changes, and I have reviewed and understood every change and can explain why each is correct.

TODO

  • Add unit tests and/or doctests in docstrings
  • Add docstrings and API docs for any new/modified user-facing classes and functions
  • New/modified features documented in docs/user-guide/*.md
  • Changes documented as a new file in changes/
  • GitHub Actions have all passed
  • Test coverage is 100% (Codecov passes)

@github-actions github-actions Bot added the needs release notes Automatically applied to PRs which haven't added release notes label Oct 21, 2026
@github-actions github-actions Bot removed the needs release notes Automatically applied to PRs which haven't added release notes label Oct 21, 2026
@codecov

codecov Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.87%. Comparing base (4a804a7) to head (4391b3a).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4542      +/-   ##
==========================================
+ Coverage   94.84%   94.87%   +0.03%     
==========================================
  Files          96       97       +1     
  Lines       13997    14091      +94     
==========================================
+ Hits        13275    13369      +94     
  Misses        722      722              
Files with missing lines Coverage Δ
src/zarr/codecs/__init__.py 100.00% <100.00%> (ø)
src/zarr/codecs/reshape.py 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@d-v-b d-v-b added this to the 3.5.0 milestone Oct 22, 2026
chunk_grid: ChunkGridMetadata,
) -> None:
"""Validate the codec configuration against the array metadata."""
self._compute_output_shape(shape)

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.

we have to validate against the chunk shape, not the array shape

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.

there's a bigger fix we need in this are that also affects sharding and transpose, see #4352. i'll try to get that merged

@clbarnes clbarnes Nov 2, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ah, I suppose that's not accessible here then - it's called against the array, not the chunk. No validation to be done here, then, as validating the shape spec is done on instantiation.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reshape codec

2 participants