def test_get_function_class(): po_class = get_function_class("Powerlaw") assert po_class == Powerlaw with pytest.raises(UnknownFunction): _ = get_function_class("not_existant")
this_model = all_models[(model_name, xspec_function, model_type)] # When the class is created it is registered among the known functions in the function module # (it happens in the metaclass), so we don't need to do anything special here after the # class type is created this_class_name, this_class = xspec_model_factory( model_name, xspec_function, model_type, this_model) classes.append(this_class_name) sys.stdout.write("done\n") return classes # This will either work or issue a warning if XSpec is not available new_functions = setup_xspec_models() # Now import the new classes in the local namespace (if any) # This is needed to make the classes pickeable __all__ = [] for function_name in new_functions: __all__.append(function_name) locals()[function_name] = get_function_class(function_name)
continue this_model = all_models[(model_name, xspec_function, model_type)] # When the class is created it is registered among the known functions in the function module # (it happens in the metaclass), so we don't need to do anything special here after the # class type is created this_class_name, this_class = xspec_model_factory(model_name, xspec_function, model_type, this_model) classes.append(this_class_name) sys.stdout.write("done\n") return classes # This will either work or issue a warning if XSpec is not available new_functions = setup_xspec_models() # Now import the new classes in the local namespace (if any) # This is needed to make the classes pickeable __all__ = [] for function_name in new_functions: __all__.append(function_name) locals()[function_name] = get_function_class(function_name)