add_to_signature

Full name: ase2sprkkr.common.decorators.add_to_signature

ase2sprkkr.common.decorators.add_to_signature(func, prepend=False, old_as_keyword=False, excluding=None, kwargs=False, apply_defaults=False)[source]

Add the arguments in the func function to the list of arguments of the resulting function (as keyword_only arguments) The modified function has to have its arguments defined as in the following example:

def parent(.....):
    ....

@add_to_signature(parent)
def child(new_param, *args, **kwargs):
    print(f'New param is {new_param})
    parent(*args, **kwargs)
Parameters:
  • func – A function, whose parameters will be added to the resulting function signature.

  • prepend –

    If True, the new positional arguments will be the first. If False, they will be after the parents positional arguments.

    If prepend=True, the order of the same-named parameters is used from the new function. Otherwise, it the different order of parameters does not overwrite the order in the “parent function”

  • old_as_keyword – If True, the original POSITIONAL_OR_KEYOWRD will be changed to keyword

  • excluding – Do not add arguments of this name(s)

  • kwargs – The resulting function will have kwargs argument

  • apply_defaults – If true, the defaults values from the “parent signature” are applied before the function is called. Otherwise, they could not applied (for the sake of the simplicity of call-wrapper) and it is presumed, that the default will be aplied by calling the func.