diff --git a/src/hdf5plugin/test.py b/src/hdf5plugin/test.py index 54ba212c..f9ed5b03 100644 --- a/src/hdf5plugin/test.py +++ b/src/hdf5plugin/test.py @@ -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 diff --git a/test/test.py b/test/test.py index 8b50eba0..1f1f9661 100644 --- a/test/test.py +++ b/test/test.py @@ -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 @@ -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 @@ -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()