Skip to content

Commit b6fdc4d

Browse files
authored
Merge pull request #290 from t20100/update-tests
SZ3 filter: Updated tests
2 parents 210771a + 32771e2 commit b6fdc4d

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/hdf5plugin/test.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,7 @@ def testSelection(self):
438438
class TestSZ(unittest.TestCase):
439439
"""Specific tests for SZ compression"""
440440

441+
@unittest.skipUnless(should_test("sz"), "SZ filter not available")
441442
def testAbsoluteMode(self):
442443
"""Test SZ's absolute mode is within required tolerance
443444

test/test.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,6 @@ def testSZ3(self):
223223
"Values should not be identical")
224224
self.assertTrue(numpy.allclose(original, output_data, atol=value),
225225
"Values should be within tolerance")
226-
self.assertTrue(numpy.alltrue(compressed == output_data),
227-
"Compressed data should be identical")
228226

229227
# relative 1E-4
230228
value = 1E-4
@@ -269,7 +267,10 @@ def testSZ3(self):
269267
self.assertTrue(original.shape == compressed.shape, "Incorrect shape")
270268
self.assertFalse(numpy.alltrue(original == compressed),
271269
"Values should not be identical")
272-
self.assertTrue(numpy.allclose(compressed, compressed_back),
270+
# Absolute error from L2 norm param from:
271+
# https://github.com/szcompressor/SZ3/blob/v3.1.8/include/SZ3/utils/Statistic.hpp#L44
272+
abs_error = numpy.sqrt(3.0/compressed.ndim) * value
273+
self.assertTrue(numpy.allclose(compressed, compressed_back, atol=abs_error),
273274
"Compressed read back values should be identical to compressed data")
274275

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

0 commit comments

Comments
 (0)