test(schema): use explicit shapes in testMultipleNullShapesDataset - #881
Merged
Merged
Conversation
The test assigned 100 randomly shaped arrays to a MultiNullShapeDataset and exported whichever one the last iteration produced. Roughly one stream offset in 250 leaves a row vector behind, and a row vector does not survive the round trip: matnwb writes any vector as a rank-1 HDF5 dataset, which MATLAB reads back as a column. Because MATLAB resets its generator only at session start, the shape reached on iteration 100 depends on how many numbers the tests before it drew. That made the failure appear on a single release and platform combination of the prepare release workflow matrix and nowhere else. Assign four explicit shapes instead, covering a scalar, a column vector, a row vector and a matrix, and export a fixed matrix. The test exercises the same shapes on every matrix job. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
ehennestad
enabled auto-merge
August 26, 2026 21:33
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #881 +/- ##
=======================================
Coverage 95.27% 95.27%
=======================================
Files 234 234
Lines 8311 8311
=======================================
Hits 7918 7918
Misses 393 393 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
bendichter
approved these changes
Aug 27, 2026
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.
Motivation
Problem — The prepare release workflow runs the test suite across every MATLAB release crossed with every platform, 36 jobs in total.
tests.unit.schema.MultipleShapesTest/testMultipleNullShapesDatasetfailed on exactly one of them, R2022a onwindows-latest, and passed on the other 35. The failure reported a shape mismatch between the exported and the re-read dataset:The test assigned 100 randomly shaped arrays to a
MultiNullShapeDatasetand exported whichever one the last iteration happened to produce. Occasionally that is a row vector, which cannot survive a round trip: MatNWB writes any vector as a rank-1 HDF5 dataset, and MATLAB reads a rank-1 dataset back as a column. MATLAB resets its random number generator only at session start, so the shape reached on iteration 100 depends on how many random numbers the tests before it drew. A release-and-platform combination that draws a different number of them lands on a different shape, which is why the failure was confined to a single matrix job and could not be reproduced from the others.Solution — Assign an explicit list of shapes instead of random ones, and export a fixed matrix. Every matrix job now exercises the same shapes, so the test either passes everywhere or fails everywhere.
What changed
testMultipleNullShapesDatasetassigns four named shapes — a scalar, a column vector, a row vector and a matrix — in place of 100 random ones.7x5matrix rather than whatever the loop left behind.Implementation notes
The orientation loss is intended and is documented under dimension ordering: one-dimensional data has to be rank-1 in the file to stay readable by other NWB implementations, and MATLAB has no rank-1 array type to read it back into.
Assigning a row vector is still valid for the type — the schema shape is
[[null], [null, null]]— so the loop keeps covering it. Only the exported value had to become orientation-stable.Examples
The shape handed to the round trip
Standing in for the random numbers drawn by earlier tests with a variable offset into the default stream shows what the exported shape depended on. Offsets 82 and 284 both end on a row vector.
Before
After
Sweeping 2001 offsets, 8 of them end on a row vector. That is the roughly 1-in-250 chance the test carried on every job.
How to test
Checklist
fix #XXwhereXXis the issue number?🤖 Generated with Claude Code