Skip to content

Encode F-contiguous arrays in logical order - #863

Open
ceedot-rock wants to merge 1 commit into
zarr-developers:mainfrom
ceedot-rock:fix-850-f-order-logical
Open

ceedot-rock wants to merge 1 commit into
zarr-developers:mainfrom
ceedot-rock:fix-850-f-order-logical

Conversation

@ceedot-rock

@ceedot-rock ceedot-rock commented Sep 25, 2026 •

Copy link
Copy Markdown

Fixes #850.

A few codecs were writing Fortran-order arrays in memory order instead of logical order (vlen, delta, fixedscaleoffset, packbits, categorize). What landed on the wire didn't match the array you thought you had, and decode either failed or gave the wrong answer.

Changes:

  • encode flattens with np.ascontiguousarray(...).reshape(-1) so the stream follows logical order
  • decode reads that stream in logical order (ndarray_copy(..., order='C'))
  • fixed a vlen case where writing into an F-ordered out= was getting thrown away

If you already encoded F-order arrays with an affected codec, those old bytes may not round-trip the same way after this. New encodes are consistent.

Happy to adjust naming or tests if you'd rather a different approach.


Slid Phi Labs accepts donations to keep the lab independent.

@codecov

codecov Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (1f83681) to head (b85aaa4).

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #863   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           27        27           
  Lines          905       904    -1     
=========================================
- Hits           905       904    -1     
Files with missing lines Coverage Δ
src/numcodecs/categorize.py 100.00% <100.00%> (ø)
src/numcodecs/compat.py 100.00% <100.00%> (ø)
src/numcodecs/delta.py 100.00% <100.00%> (ø)
src/numcodecs/fixedscaleoffset.py 100.00% <100.00%> (ø)
src/numcodecs/packbits.py 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ceedot-rock
ceedot-rock force-pushed the fix-850-f-order-logical branch from 3ccf9f4 to f484c82 Compare September 25, 2026 18:41
@ceedot-rock

Copy link
Copy Markdown
Author

@alimanfoo this one's ready for review when you have a chance — fixes the F-order encode path from #850.

A few codecs were walking Fortran-layout arrays in memory order,
so the encoded bytes didn’t match the logical data. Encode now
flattens in C order; decode reads the stream that way too.

Also notes the change under Unreleased in docs/release.md.

Fixes zarr-developers#850.
@ceedot-rock
ceedot-rock force-pushed the fix-850-f-order-logical branch from f484c82 to b85aaa4 Compare October 4, 2026 15:27
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.

vlen and filter codecs encode F-contiguous arrays in memory order, not logical order

1 participant