fix(batch): validate Batch metadata dimensions in __post_init__ - #196
Open
xerxeschongxian26 wants to merge 1 commit into
Open
Conversation
- Add __post_init__ to Batch that asserts len(metadata.time) equals the batch size and len(metadata.atmos_levels) equals the pressure-level dimension, raising ValueError on mismatch. - Use shape[-3] for the atmos level check so validation works for both input (b, t, c, h, w) and decoder output (b, c, h, w) batches. - Align test_aurora_small with the metadata.time contract for batch size two. Add unhappy-path tests in tests/test_batch.py.
Author
|
@microsoft-github-policy-service agree |
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.
Fixes #188
Add
__post_init__toBatchthat assertslen(metadata.time)equals the batch size andlen(metadata.atmos_levels)equals the pressure-level dimension, raisingValueErroron mismatch.Use
shape[-3]for the atmos level check so validation works for both input(b, t, c, h, w)and decoder output(b, c, h, w)batches.Align
test_aurora_smallwith themetadata.timecontract for batch size two. Add unhappy-path tests intests/test_batch.py.Test plan
tests/test_headers.py(skipped locally due to.venvcrawl) — 49 passed ...Note: This PR was drafted with AI assistance.
@wesselb