Skip to content

fix(blob): preserve character matrix orientation (#1702) - #1743

Open
godara-alt wants to merge 3 commits into
datajoint:masterfrom
godara-alt:fix/1702-char-array-order
Open

godara-alt wants to merge 3 commits into
datajoint:masterfrom
godara-alt:fix/1702-char-array-order

Conversation

@godara-alt

@godara-alt godara-alt commented Nov 21, 2026 •

Copy link
Copy Markdown

Summary

Fixes #1702.

Character matrices with multiple rows were serialized in row-major order but decoded in column-major order, causing their elements to be rearranged during blob round-trips.

Root Cause

The CHAR serialization path in Blob.pack_array() used tobytes() without specifying the memory order, while Blob.read_array() reconstructs arrays using reshape(shape, order="F").

This mismatch caused multi-row character matrices to return with incorrect element positions.

Changes

  • Serialize CHAR array data using tobytes(order="F") to match MATLAB's column-major representation.
  • Preserve the existing blob decoding behavior.
  • Add regression tests for 2×3, 3×2, and 2×2 character matrices.
  • Verify the serialized character byte order.
  • Add compressed character-matrix round-trip coverage.

Validation

  • Fork GitHub Actions: Test and Lint passed on commit f8cf4c6.
  • Upstream PR GitHub Actions: Lint passed; Test workflow is still running.
  • Added regression tests for character matrix orientation, MATLAB-compatible byte ordering, and compressed round-trips.
  • Existing blob decoder remains unchanged.

Scope

Changes are limited to:

  • src/datajoint/blob.py
  • tests/unit/test_blob_character_arrays.py

Previously stored blob data retains its existing decoding behavior.

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.

Character matrices with more than one row come back transposed from <blob>

1 participant