Skip to content

Commit 1c8aea6

Browse files
authored
Merge pull request #268 from t20100/fix-sz-build
LGTM
2 parents e01716c + 9f47366 commit 1c8aea6

2 files changed

Lines changed: 33 additions & 4 deletions

File tree

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,8 +1081,8 @@ def get_sz_plugin():
10811081
sz_dir = "src/SZ/sz"
10821082
h5zsz_dir = "src/SZ/hdf5-filter/H5Z-SZ"
10831083

1084-
extra_compile_args = ['-O3', '-ffast-math', '-std=c99', '-fopenmp']
1085-
extra_compile_args += ['/Ox', '/fp:fast', '/openmp']
1084+
extra_compile_args = ['-O3', '-std=c99', '-fopenmp']
1085+
extra_compile_args += ['/Ox', '/openmp']
10861086
extra_link_args = ['-fopenmp', '/openmp', "-lm"]
10871087

10881088
include_dirs = [f'{h5zsz_dir}/include']

src/hdf5plugin/test.py

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# coding: utf-8
22
# /*##########################################################################
33
#
4-
# Copyright (c) 2019-2022 European Synchrotron Radiation Facility
4+
# Copyright (c) 2019-2023 European Synchrotron Radiation Facility
55
#
66
# Permission is hereby granted, free of charge, to any person obtaining a copy
77
# of this software and associated documentation files (the "Software"), to deal
@@ -429,9 +429,38 @@ def testSelection(self):
429429
self.assertEqual(hdf5plugin.get_filters(filters), ref)
430430

431431

432+
class TestSZ(unittest.TestCase):
433+
"""Specific tests for SZ compression"""
434+
435+
def testAbsoluteMode(self):
436+
"""Test SZ's absolute mode is within required tolerance
437+
438+
See https://github.com/silx-kit/hdf5plugin/issues/267
439+
"""
440+
tolerance = 0.01
441+
442+
numpy.random.seed(0)
443+
data = numpy.random.random(size=(1000, 25, 25)).astype(numpy.float32)
444+
445+
compression = hdf5plugin.SZ(absolute=tolerance)
446+
447+
with tempfile.TemporaryDirectory() as tempdir:
448+
filename = os.path.join(tempdir, "testsz.h5")
449+
with h5py.File(filename, 'w', driver="core", backing_store=False) as f:
450+
f.create_dataset('var', data=data, chunks=data.shape, **compression)
451+
f.flush()
452+
453+
recovered_data = f["var"][:]
454+
455+
self.assertTrue(
456+
numpy.allclose(data, recovered_data, atol=tolerance),
457+
f"Condition not fulfilled for {tolerance} -> {numpy.max(numpy.abs(recovered_data - data))}"
458+
)
459+
460+
432461
def suite():
433462
test_suite = unittest.TestSuite()
434-
for cls in (TestHDF5PluginRW, TestPackage, TestRegisterFilter, TestGetFilters):
463+
for cls in (TestHDF5PluginRW, TestPackage, TestRegisterFilter, TestGetFilters, TestSZ):
435464
test_suite.addTest(unittest.TestLoader().loadTestsFromTestCase(cls))
436465
return test_suite
437466

0 commit comments

Comments
 (0)