Skip to content

Fix ShardWriter round-trip test: missing assertions and degenerate bool data - #397

Merged
kralka merged 1 commit into
google:mainfrom
marcus-campbell:fix/flatbuffer-roundtrip-assertions
Aug 20, 2026
Merged

Fix ShardWriter round-trip test: missing assertions and degenerate bool data#397
kralka merged 1 commit into
google:mainfrom
marcus-campbell:fix/flatbuffer-roundtrip-assertions

Conversation

@marcus-campbell

@marcus-campbell marcus-campbell commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Description

This test had two bugs that weakened its intended coverage:

  • np.array_equal(...) was called without checking its return value, so the read-back comparisons never actually asserted anything. The fix replaces this with np.testing.assert_array_equal, which raises on mismatch.

  • The bool attribute used np.random.randint(0, 1, ...), which always returns 0 (its upper bound is exclusive), so only all-False data was round-tripped. The fix replaces this with an explicit array containing both True and False.

Testing

  • python -m pytest tests/io/shard/test_shard_writer_flatbuffer.py tests/io/shard/test_shard_write_and_read.py - all 14 passed, with four existing unsigned-cast warnings.

AI Disclosure

I didn't use AI to write any of this code, but I technically found these bugs during an AI-assisted static analysis project that I've been working on. The AI assisting me was OpenAI Codex gpt-5.6-sol (xhigh). Just stating that for transparency; maintainers, just yell if this disclosure is too pedantic.

The test called np.array_equal without checking its return value, so
decode mismatches were silently ignored. Replace with
np.testing.assert_array_equal so failures raise. Also replace randint(0,
1) with an explicit array so the bool attribute round-trip is tested
with both True and False values.
@kralka

kralka commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator

Nice finds, thank you!

@coveralls

coveralls commented Aug 20, 2026

Copy link
Copy Markdown

Coverage Report for CI Build 32335605095

Warning

No base build found for commit 8265d86 on main.
Coverage changes can't be calculated without a base build.
If a base build is processing, this comment will update automatically when it completes.

Coverage: 88.617%

Details

  • Patch coverage: 11 of 11 lines across 1 file are fully covered (100%).

Uncovered Changes

No uncovered changes found.

Coverage Regressions

Requires a base build to compare against. How to fix this →


Coverage Stats

Coverage Status
Relevant Lines: 3470
Covered Lines: 3075
Line Coverage: 88.62%
Coverage Strength: 1.77 hits per line

💛 - Coveralls

@kralka
kralka added this pull request to the merge queue Aug 20, 2026
Merged via the queue into google:main with commit 79f548e Aug 20, 2026
100 of 105 checks passed
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.

3 participants