Skip to content

Add relative and absolute tolerance support to testing utilities (#3244)#4041

Open
myuau wants to merge 4 commits intoUnidata:mainfrom
myuau:fix-precision-capture
Open

Add relative and absolute tolerance support to testing utilities (#3244)#4041
myuau wants to merge 4 commits intoUnidata:mainfrom
myuau:fix-precision-capture

Conversation

@myuau
Copy link
Copy Markdown

@myuau myuau commented Apr 20, 2026

Description of Changes

Addresses #3244 by adding relative (rtol) and absolute (atol) tolerance support to MetPy's testing utilities. This enables more precise scientific testing across varying magnitudes where fixed decimal precision is insufficient.

Proposed Changes

metpy/testing.py Updates

  • assert_almost_equal & assert_array_almost_equal: Added rtol and atol parameters. Now wraps numpy.testing.assert_allclose when these are provided.
  • assert_xarray_allclose: Updated to pass rtol and atol through to xarray.testing.assert_allclose.
  • Backward Compatibility: Maintained decimal as the default behavior.

Checklist

  • Code follows project style guidelines
  • Self-review performed
  • No new warnings generated

Fixes #3244

@myuau myuau requested a review from a team as a code owner April 20, 2026 03:49
@myuau myuau requested review from dcamron and removed request for a team April 20, 2026 03:49
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.

Consider assert_allclose

1 participant