[docs]defset_attributes(my_object,attributes_dict):forkey,valueinattributes_dict.items():ifkeyinmy_object.__dict__:setattr(my_object,key,value)else:rise_warning("trying to set a non existing attribute "+str(key)+" in "+str(type(my_object)))return0
[docs]defcheck_function_kwargs(func:Callable,kwargs:dict)->dict:""" check that the keys of a dictionnary are arguments of a function and return an updated dictionnary with only valide keys Parameters ---------- func : function function to check kwargs : dict dictionnary of arguments to check Returns ------- dict updated kwargs dictionnary """func_kwargs_set=set(func.__code__.co_varnames[:func.__code__.co_argcount])kwargs_set=set(kwargs.keys())not_valid_kwargs_set=kwargs_set-func_kwargs_setforkinnot_valid_kwargs_set:kwargs.pop(k)returnkwargs