Repository navigation
Conversation
A test-only array-to-array codec records the dtype of every array it encodes. Run over value and array byte order, chunk coverage, sharding and both codec pipelines, it fails on main for every byte-swapped write that covers a whole chunk or shard, whatever any real codec tolerates. Assisted-by: ClaudeCode:claude-opus-5-5 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rings and datetimes The big-endian CI job runs tests/test_array.py but not new top-level test files. Also cover U3 and M8[s] values, check that every touched chunk was encoded, and name the byte-order parameters. Assisted-by: ClaudeCode:claude-opus-5-5 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Assisted-by: ClaudeCode:claude-opus-5-5 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Assisted-by: ClaudeCode:claude-opus-5-5 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
🤖 AI text below 🤖
Added a test that checks every array an array-to-array codec encodes is in the array's byte order, including writes of byte-swapped values that cover whole chunks. A test-only codec records what it receives, so the test keeps catching regressions in
_set_selectioneven after real codecs learn to tolerate non-native input.Stack. This PR is stacked on #473 (
fix/structured-whole-record-cast), which contains the fix this test covers, and targets that branch. Merge #473 first, then retarget this PR tomain. It stays a draft until then. Related: #476 makes numcodecs filters andcast_valueconvert non-native byte order themselves. That is why this test does not rely on any real codec to detect the bug.What the test covers
_set_selectioncasts a written value to the array's native dtype only when the dtypes differ. Before #473, it compareddtype.name, which ignores byte order:<i4and>i4are both"int32". Soa[0:4] = values.astype(">i4")on a<i4array passed big-endian bytes to the codecs whenever the write covered whole chunks. Partial chunks were already converted when the value was merged into the existing chunk. Before #473, a whole-chunk>i4write to a<i4array came back corrupted through numcodecsDeltaandFixedScaleOffset, under both pipelines.#473's
test_write_casts_value_to_array_dtypecovers byte order only as a guard: it uses the default codecs, which handle swapped input, so it passes with or without the fix. This PR addstest_written_values_reach_codecs_in_array_byte_ordertotests/test_array.py, plus a module-level test-only codec_RecordEncodedDtype. The codec is an identity codec that records(received dtype, chunk spec native dtype)for each array it encodes, on both the sync and async paths. The test runs over:</>, so both hosts' native order is covered);BatchedCodecPipelineandFusedCodecPipeline;i4,f8,c8,U3,M8[s].It asserts that each touched chunk was encoded, that every received dtype equals the chunk spec's native dtype, that the spec dtype is the array's dtype, and that the values read back unchanged. There are no error cases to test: the change is test-only.
tests/test_array.pybecause the big-endian s390x job (.github/workflows/big-endian.yml) runs that file.uv run pytest tests -n 8: 13884 passed, 1360 skipped, 9 xfailed. That run was on the first commit;tests/test_array.pywas rerun after the later commits: 2865 passed, 796 skipped. ruff, mypy and numpydoc are clean.Adversarial review
Fresh reviewer agents got the diff, not the author's conclusions. Neither round found a serious problem, so the loop stopped after round 2.
Round 1 (on e74fc14, test in its own file):
tests/test_array.py.U3,M8[s],m8[s]andu2values also reached the codecs swapped onmain. Fixed in c853c57 by addingU3andM8[s].assert recorder.seenonly checked non-empty (nit). Fixed in c853c57: the test now asserts at least one encode per touched chunk.Round 2 (on c853c57):
==instead of>=for the encode count (nit). Rejected: whether a pipeline re-encodes untouched inner chunks is an implementation detail, and a re-encoded chunk is still checked for its dtype.Both rounds reproduced the result above: the test fails without the fix and passes with it. They also checked behavior on a big-endian host, the sharded inner chain, the sync and async encode paths, and that the new codec class does not leak into other tests.
🤖 Generated with Claude Code