MCPcopy Create free account
hub / github.com/Project-MONAI/MONAI / check_kwargs_exist_in_class_init

Function check_kwargs_exist_in_class_init

monai/utils/misc.py:857–874  ·  view source on GitHub ↗

Check if the all keys in kwargs exist in the __init__ method of the class. Args: cls: the class to check. kwargs: kwargs to examine. Returns: a boolean indicating if all keys exist. a set of extra keys that are not used in the __init__.

(cls, kwargs)

Source from the content-addressed store, hash-verified

855
856
857def check_kwargs_exist_in_class_init(cls, kwargs):
858 """
859 Check if the all keys in kwargs exist in the __init__ method of the class.
860
861 Args:
862 cls: the class to check.
863 kwargs: kwargs to examine.
864
865 Returns:
866 a boolean indicating if all keys exist.
867 a set of extra keys that are not used in the __init__.
868 """
869 init_signature = inspect.signature(cls.__init__)
870 init_params = set(init_signature.parameters) - {"self"} # Exclude 'self' from the parameter list
871 input_kwargs = set(kwargs)
872 extra_kwargs = input_kwargs - init_params
873
874 return extra_kwargs == set(), extra_kwargs
875
876
877def run_cmd(cmd_list: list[str], **kwargs: Any) -> subprocess.CompletedProcess:

Calls

no outgoing calls

Tested by 1

_custom_user_functionMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…