Skip to content

Commit

Permalink
Merge pull request #290 from t20100/update-tests
Browse files Browse the repository at this point in the history
SZ3 filter: Updated tests
  • Loading branch information
vasole committed Jan 24, 2024
2 parents 210771a + 32771e2 commit b6fdc4d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
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")
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),
"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
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

0 comments on commit b6fdc4d

Please sign in to comment.