bilby.compat.utils.xp_wrap

bilby.compat.utils.xp_wrap(func, no_xp=False)[source]

A decorator that will figure out the array module from the input arguments and pass it to the function as the ‘xp’ keyword argument.

Parameters:
func: function

The function to be decorated.

no_xp: bool

If True, the decorator will not attempt to add the ‘xp’ keyword argument and so the wrapper is a no-op.

Returns:
function

The decorated function.