make_function_with_signature#
- astropy.utils.codegen.make_function_with_signature(func, args=(), kwargs={}, varargs=None, varkwargs=None, name=None)[source]#
Make a new function from an existing function but with the desired signature.
The desired signature must of course be compatible with the arguments actually accepted by the input function.
The
args
are strings that should be the names of the positional arguments.kwargs
can map names of keyword arguments to their default values. It may be either adict
or a list of(keyword, default)
tuples.If
varargs
is a string it is added to the positional arguments as*<varargs>
. Likewisevarkwargs
can be the name for a variable keyword argument placeholder like**<varkwargs>
.If not specified the name of the new function is taken from the original function. Otherwise, the
name
argument can be used to specify a new name.Note, the names may only be valid Python variable names.