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
argsare strings that should be the names of the positional arguments.kwargscan map names of keyword arguments to their default values. It may be either adictor a list of(keyword, default)tuples.If
varargsis a string it is added to the positional arguments as*<varargs>. Likewisevarkwargscan 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
nameargument can be used to specify a new name.Note, the names may only be valid Python variable names.