Skip to content

Commit

Permalink
rename REGISTERED_FITLERS to registered_filters (it's not a constant)
Browse files Browse the repository at this point in the history
  • Loading branch information
t20100 committed Nov 23, 2022
1 parent a95ade8 commit 1f31c4e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
18 changes: 9 additions & 9 deletions src/hdf5plugin/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def is_filter_available(name):
return h5py.h5z.filter_avail(filter_id) > 0


REGISTERED_FILTERS = {}
registered_filters = {}
"""Store hdf5plugin registered filters as a mapping: name: (filename, ctypes.CDLL)"""


Expand Down Expand Up @@ -94,7 +94,7 @@ def register_filter(name):
except RuntimeError:
logger.debug("Filter %s (%d) not unregistered" % (name, filter_id))
logger.debug(traceback.format_exc())
REGISTERED_FILTERS.pop(name, None)
registered_filters.pop(name, None)

# Load DLL
filename = glob.glob(os.path.join(
Expand Down Expand Up @@ -127,7 +127,7 @@ def register_filter(name):
return False

logger.debug("Registered filter: %s (%s)", name, filename)
REGISTERED_FILTERS[name] = filename, lib
registered_filters[name] = filename, lib
return True


Expand All @@ -140,16 +140,16 @@ def register_filter(name):
def get_config():
"""Provides information about build configuration and filters registered by hdf5plugin.
"""
registered_filters = {}
filters = {}
for name in FILTERS:
info = REGISTERED_FILTERS.get(name)
info = registered_filters.get(name)
if info is not None: # Registered by hdf5plugin
if is_filter_available(name) in (True, None):
registered_filters[name] = info[0]
filters[name] = info[0]
elif is_filter_available(name) is True: # Registered elsewhere
registered_filters[name] = "unknown"
filters[name] = "unknown"

return HDF5PluginConfig(build_config, registered_filters)
return HDF5PluginConfig(build_config, filters)


def register(filters=tuple(FILTERS.keys()), force=True):
Expand All @@ -166,7 +166,7 @@ def register(filters=tuple(FILTERS.keys()), force=True):
:rtype: bool
"""
if isinstance(filters, str):
names = (filters,)
filters = (filters,)

status = True
for filter_name in filters:
Expand Down
14 changes: 7 additions & 7 deletions src/hdf5plugin/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,19 +283,19 @@ def _simple_test(self, filter_name):
@unittest.skipUnless(hdf5plugin.config.embedded_filters, "No embedded filters")
def test_register_single_filter(self):
"""Re-register embedded filters one at a time"""
for name in hdf5plugin.config.embedded_filters:
with self.subTest(name=name):
status = hdf5plugin.register(name, force=True)
for filter_name in hdf5plugin.config.embedded_filters:
with self.subTest(name=filter_name):
status = hdf5plugin.register(filter_name, force=True)
self.assertTrue(status)
self._simple_test(name)
self._simple_test(filter_name)

@unittest.skipUnless(hdf5plugin.config.embedded_filters, "No embedded filters")
def test_register_all_filters(self):
"""Re-register embedded filters all at once"""
status = hdf5plugin.register()
for name in hdf5plugin.config.embedded_filters:
with self.subTest(name=name):
self._simple_test(name)
for filter_name in hdf5plugin.config.embedded_filters:
with self.subTest(name=filter_name):
self._simple_test(filter_name)


def suite():
Expand Down

0 comments on commit 1f31c4e

Please sign in to comment.