baybe.utils.basic.match_attributes

baybe.utils.basic.match_attributes(object: Any, callable_: Callable, /, strict: bool = True, ignore: Collection[str] = ())[source]

Find the attributes of an object that match with a given callable signature.

Parameters appearing in the callable signature that have no match with the given object attributes are ignored.

Parameters:
  • object (Any) – The object whose attributes are to be matched.

  • callable – The callable against whose signature the attributes are to be matched.

  • strict (bool) – If True, an error is raised when the object has attributes that are not found in the callable signature (see also ignore). If False, these attributes are returned separately.

  • ignore (Collection[str]) – A collection of attributes names that are to be ignored during matching.

Raises:
Return type:

tuple[dict[str, Any], dict[str, Any]]

Returns:

  • A dictionary mapping the matched attribute names to their values.

  • A dictionary mapping the unmatched attribute names to their values.