Signature#
signature module#
- mmodel.signature.check_args(base_params, arglist)[source]#
Check if args list is valid.
- Parameters:
base_params (list) – list of signature parameters
arglist (list) – list of positional arguments
- mmodel.signature.check_kwargs(base_params, kwarglist)[source]#
Check if kwargs list is valid.
- Parameters:
base_params (list) – list of signature parameters
kwarglist (list) – list of keyword arguments
- mmodel.signature.check_signature(base_params, param_list, param_type, nonvar_kind, var_kind)[source]#
Check if the function signature is valid.
Check for the number of parameters based on original signature requirements.
- mmodel.signature.convert_func(func, sig)[source]#
Wrap the input node function and redirect the input parameters.
The signature is constructed in the node definition that defines the new signature following the old signature. The wrapper splits the arguments into positional and keyword arguments, and applies them to the function.
- mmodel.signature.get_node_signature(base_params, inputs_list)[source]#
Get the node signature based on the function and argument lists.
If the inputs_list is empty, the function returns the signature with only the required parameters and no var-parameters. If the inputs_list is not empty, the function checks if the argument lists meet the minimum and maximum requirements of the function. The inputs can be separated by “*” to indicate keyword-only parameters.
- Parameters:
base_params (list) – list of parameters
inputs_list (list) – list of input parameters
- mmodel.signature.get_parameters(func)[source]#
Get the parameter list for the function.
If the function has no signature, the function returns a list with *args and **kwargs. Empty input definition is allowed; therefore, a function without a signature and without argument lists is valid.
- Parameters:
func (callable) – function to get the parameters from
- mmodel.signature.restructure_signature(signature, default_dict)[source]#
Add defaults to signature for Model.
Here the parameter kinds are replaced with kind defaults to positional-or-keyword, and defaults are applied. The final signature is sorted.
- Parameters:
signature (inspect.Signature) – signature to add defaults to
default_dict (dict) – default values for the parameters