def test_register_library(self, library): apilib = import_module('gwpy.signal.fft.{}'.format(library)) regname = str if library == 'basic' else ('%s_{}' % library).format for method in ('welch', 'bartlett', 'median', 'median_mean'): if method == 'median' and library == 'scipy': break assert (fft_registry.get_method(regname(method)) is getattr( apilib, method))
def test_register_library(self, library): apilib = import_module('gwpy.signal.fft.{}'.format(library)) regname = str if library == 'basic' else ('%s_{}' % library).format for method in ('welch', 'bartlett', 'median', 'median_mean'): if method == 'median' and library == 'scipy': break assert ( fft_registry.get_method(regname(method)) is getattr(apilib, method))
def test_registry(self): """Test :mod:`gwpy.signal.fft.registry` """ def fake_method(): pass # test register fft_registry.register_method(fake_method) assert 'fake_method' in fft_registry.METHODS['density'] with pytest.raises(KeyError): fft_registry.register_method(fake_method) fft_registry.register_method(fake_method, force=True) assert 'fake_method' in fft_registry.METHODS['density'] fft_registry.register_method(fake_method, scaling='spectrum') assert 'fake_method' in fft_registry.METHODS['spectrum'] with pytest.raises(KeyError): fft_registry.register_method(fake_method, scaling='unknown') # test get f = fft_registry.get_method('fake_method') assert f is fake_method with pytest.raises(KeyError): fft_registry.get_method('unregistered') with pytest.raises(KeyError): fft_registry.get_method('fake_method', scaling='unknown')