Repository navigation
Conversation
Yi-111-a
force-pushed
the
fix-numcodecs-encode-reshape
branch
from
October 26, 2026 03:47
2be4fd7 to
e3d6d20
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4560 +/- ##
=======================================
Coverage 94.71% 94.71%
=======================================
Files 94 94
Lines 13663 13665 +2
=======================================
+ Hits 12941 12943 +2
Misses 722 722
🚀 New features to boost your workflow:
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #4553.
What and why
_NumcodecsArrayArrayCodec._encode_syncnow reshapes a flattened numcodecs filter output back to the chunk shape before handing it to the next codec, mirroring what_decode_syncalready does on the way out. Filters likeDeltaandFixedScaleOffsetreturn a 1-D array, so downstream codecs (e.g. theimagecodecsJPEG-XR serializer from the issue, or aTransposeCodecright after the filter) previously received a1 × Nchunk instead of the 2-D chunk shape: writing failed outright (axes don't match array,JpegxrError) or data was silently corrupted. Filenames in the issue's 'patched' output show the exact failures this fixes.Only flattened outputs whose element count equals the chunk size are reshaped; shape-changing ArrayArray codecs keep their output (e.g.
PackBits, whose packed output isceil(N/8) + 1bytes — reshaping that would have been wrong).Note: the issue's proposed patch reshaped unconditionally; this PR keeps that behavior only when the flattened output is exactly chunk-sized so
PackBits(covered by existing tests) still works.Testing
New
test_generic_filter_flattened_output_reshaped(Delta→TransposeCodec) fails onmainand passes with this change; newtest_generic_filter_packedbits_output_not_reshapedguards the size-mismatch path. Fulltests/test_codecs/test_numcodecs.py(94),test_transpose.pyandtest_fastpath_equivalence.pyall pass;ruff checkandruff format --checkclean.