Skip to content

fix(batch): validate Batch metadata dimensions in __post_init__ - #196

Open
xerxeschongxian26 wants to merge 1 commit into
microsoft:mainfrom
xerxeschongxian26:fix/188-validate-metadata-time-and-atmos-level-length
Open

fix(batch): validate Batch metadata dimensions in __post_init__#196
xerxeschongxian26 wants to merge 1 commit into
microsoft:mainfrom
xerxeschongxian26:fix/188-validate-metadata-time-and-atmos-level-length

Conversation

@xerxeschongxian26

@xerxeschongxian26 xerxeschongxian26 commented Jul 25, 2026

Copy link
Copy Markdown

Fixes #188

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.

Test plan

  • Ran full local suite except tests/test_headers.py (skipped locally due to .venv crawl) — 49 passed ...
  • Pre-commit hooks pass locally

Note: This PR was drafted with AI assistance.

@wesselb

- 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.
@xerxeschongxian26
xerxeschongxian26 requested a review from a team July 25, 2026 12:03
@xerxeschongxian26

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

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.

Missing validation: Silent output-shape corruption when len(Metadata.time) != batch size

1 participant