Relax tolerance for HCOMPRESS_1 tests with quantization #18476
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.
Description
This pull request addresses test failures in
test_fitsio.py::test_compress
for HCOMPRESS_1 compression with SUBTRACTIVE_DITHER_2 quantization method by relaxing the comparison tolerances to account for the expected precision differences in lossy compression.The HCOMPRESS_1 algorithm with quantization method 2 (SUBTRACTIVE_DITHER_2) is inherently lossy, which leads to small precision differences when comparing data compressed by different implementations (fitsio vs astropy). The tests were using NumPy's default tolerances (
rtol=1e-7, atol=0
), which were too strict for this lossy compression method.Changes Made
test_compress()
inastropy/io/fits/hdu/compressed/tests/test_fitsio.py
ZQUANTIZ
header)rtol=1e-5, atol=1e-5
) for these specific cases onlyTest Results
All 15 previously failing tests now pass:
HCOMPRESS_1 {'qlevel': 20, 'qmethod': 2}
with various float types (<f4, <f8, >f4, >f8)The reported maximum differences were:
Our chosen tolerances provide appropriate coverage with a safety margin.
Impact
This is a test-only change with no impact on the actual compression/decompression functionality. It only affects how strictly we compare results for this specific lossy compression method.
Fixes #18468
Checklist