pydvl.utils.functional
¶
Supporting utilities for manipulating arguments of functions.
free_arguments
¶
Computes the set of free arguments for a function or functools.partial object.
All arguments of a function are considered free unless they are set by a
partial. For example, if f = partial(g, a=1)
, then a
is not a free
argument of f
.
New in version 0.7.0
Source code in src/pydvl/utils/functional.py
maybe_add_argument
¶
Wraps a function to accept the given keyword parameter if it doesn't already.
If fun
already takes a keyword parameter of name new_arg
, then it is
returned as is. Otherwise, a wrapper is returned which merely ignores the
argument.
RETURNS | DESCRIPTION |
---|---|
Callable
|
A new function accepting one more keyword argument. |
Changed in version 0.7.0
Ability to work with partials.