Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SZ3 filter: Updated tests #290

Merged
merged 2 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/hdf5plugin/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@ def testSelection(self):
class TestSZ(unittest.TestCase):
"""Specific tests for SZ compression"""

@unittest.skipUnless(should_test("sz"), "SZ filter not available")
vasole marked this conversation as resolved.
Show resolved Hide resolved
def testAbsoluteMode(self):
"""Test SZ's absolute mode is within required tolerance

Expand Down
9 changes: 5 additions & 4 deletions test/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,6 @@ def testSZ3(self):
"Values should not be identical")
self.assertTrue(numpy.allclose(original, output_data, atol=value),
"Values should be within tolerance")
self.assertTrue(numpy.alltrue(compressed == output_data),
vasole marked this conversation as resolved.
Show resolved Hide resolved
"Compressed data should be identical")

# relative 1E-4
value = 1E-4
Expand Down Expand Up @@ -269,7 +267,10 @@ def testSZ3(self):
self.assertTrue(original.shape == compressed.shape, "Incorrect shape")
self.assertFalse(numpy.alltrue(original == compressed),
"Values should not be identical")
self.assertTrue(numpy.allclose(compressed, compressed_back),
# Absolute error from L2 norm param from:
# https://github.com/szcompressor/SZ3/blob/v3.1.8/include/SZ3/utils/Statistic.hpp#L44
abs_error = numpy.sqrt(3.0/compressed.ndim) * value
vasole marked this conversation as resolved.
Show resolved Hide resolved
self.assertTrue(numpy.allclose(compressed, compressed_back, atol=abs_error),
"Compressed read back values should be identical to compressed data")

# create a compressed file
Expand All @@ -282,7 +283,7 @@ def testSZ3(self):
"Values should not be identical")
self.assertTrue(numpy.alltrue(compressed == output_data),
"Compressed data should be identical")
self.assertTrue(numpy.allclose(compressed_back, output_data),
self.assertTrue(numpy.allclose(compressed_back, output_data, atol=abs_error),
"Newly L2 norm read back values should be identical to compressed data")
h5.close()

Expand Down
Loading