pyufunc.requires#
- pyufunc.requires(*args, **kwargs)#
Wrap a function with extra dependency checks.
If the dependencies are not available, the function will not run.
- Parameters:
*args – Required dependency specifications. Each value can be a package name string, or a two-item tuple/list of
(install_name, import_name)when the installation name differs from the import name.**kwargs – Optional decorator settings. Supported keys are
verbosefor printing dependency messages andauto_installfor explicitly installing missing packages.verbosedefaults toTrueandauto_installdefaults toFalse.
Notes
Missing dependencies are reported and the wrapped function is skipped. Dependencies are installed only when
auto_install=Trueis passed explicitly.Examples
>>> @requires("numpy", "pandas", verbose=False) ... def my_function(): ... return "I'm running!" >>> my_function() "I'm running!"
- Returns:
The decorated function wrapper.