MCPcopy
hub / github.com/pydata/xarray / compat_dict_union

Function compat_dict_union

xarray/core/utils.py:465–491  ·  view source on GitHub ↗

Return the union of two dictionaries as a new dictionary. An exception is raised if any keys are found in both dictionaries and the values are not compatible. Parameters ---------- first_dict, second_dict : dict-like Mappings to merge. compat : function, optional

(
    first_dict: Mapping[K, V],
    second_dict: Mapping[K, V],
    compat: Callable[[V, V], bool] = equivalent,
)

Source from the content-addressed store, hash-verified

463
464
465def compat_dict_union(
466 first_dict: Mapping[K, V],
467 second_dict: Mapping[K, V],
468 compat: Callable[[V, V], bool] = equivalent,
469) -> MutableMapping[K, V]:
470 """Return the union of two dictionaries as a new dictionary.
471
472 An exception is raised if any keys are found in both dictionaries and the
473 values are not compatible.
474
475 Parameters
476 ----------
477 first_dict, second_dict : dict-like
478 Mappings to merge.
479 compat : function, optional
480 Binary operator to determine if two values are compatible. By default,
481 checks for equivalence.
482
483 Returns
484 -------
485 union : dict
486 union of the contents.
487 """
488 new_dict = dict(first_dict)
489 update_safety_check(first_dict, second_dict, compat)
490 new_dict.update(second_dict)
491 return new_dict
492
493
494class Frozen(Mapping[K, V]):

Callers 1

merge_attrsFunction · 0.90

Calls 2

update_safety_checkFunction · 0.85
updateMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…