fix(batch): validate Batch metadata dimensions in __post_init__ - #196
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.
|
@microsoft-github-policy-service agree |
|
Hi Wessel (@wesselb) , just a gentle bump on this whenever you have a moment. No rush at all; I know reviews compete with plenty of other work! Happy to make any changes if anything needs adjusting and fixing. Thanks again for the nudge to open the PR :) |
Wessel (wesselb)
left a comment
There was a problem hiding this comment.
Thanks Xerxes Chong (@xerxeschongxian26) for putting this together! This looks good to me. :) I've left a few minor suggestions.
|
Thank you for the review Wessel (@wesselb) and your suggestions! I am glad to have been able to contribute! I believe the PR is now ready for merging! |
|
Xerxes Chong (@xerxeschongxian26) If you meant to accept the suggestions, then you'll need to click "Apply suggestion" instead of resolving the comments. Currently I think you resolved them all without applying. I'll unresolve them for now. :) If you're happy with all suggestions, then let's apply them and merge this in! |
Co-authored-by: Wessel <wessel.p.bruinsma@gmail.com>
Co-authored-by: Wessel <wessel.p.bruinsma@gmail.com>
Co-authored-by: Wessel <wessel.p.bruinsma@gmail.com>
Co-authored-by: Wessel <wessel.p.bruinsma@gmail.com>
Co-authored-by: Wessel <wessel.p.bruinsma@gmail.com>
|
Wessel (@wesselb) Hello Wessel, thanks for the correction. I have now applied the suggestions, should all be ready now! |
Wessel (wesselb)
left a comment
There was a problem hiding this comment.
Thanks! Looking great now
|
Wessel (@wesselb) Great! It looks finally ready now! |
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.
Wessel (@wesselb)