MCPcopy Index your code
hub / github.com/pydata/xarray / update_safety_check

Function update_safety_check

xarray/core/utils.py:291–316  ·  view source on GitHub ↗

Check the safety of updating one dictionary with another. Raises ValueError if dictionaries have non-compatible values for any key, where compatibility is determined by identity (they are the same item) or the `compat` function. Parameters ---------- first_dict, second_dict

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

Source from the content-addressed store, hash-verified

289
290
291def update_safety_check(
292 first_dict: Mapping[K, V],
293 second_dict: Mapping[K, V],
294 compat: Callable[[V, V], bool] = equivalent,
295) -> None:
296 """Check the safety of updating one dictionary with another.
297
298 Raises ValueError if dictionaries have non-compatible values for any key,
299 where compatibility is determined by identity (they are the same item) or
300 the `compat` function.
301
302 Parameters
303 ----------
304 first_dict, second_dict : dict-like
305 All items in the second dictionary are checked against for conflicts
306 against items in the first dictionary.
307 compat : function, optional
308 Binary operator to determine if two values are compatible. By default,
309 checks for equivalence.
310 """
311 for k, v in second_dict.items():
312 if k in first_dict and not compat(v, first_dict[k]):
313 raise ValueError(
314 "unsafe to merge dictionaries without "
315 f"overriding values; conflicting key {k!r}"
316 )
317
318
319def remove_incompatible_items(

Callers 1

compat_dict_unionFunction · 0.85

Calls 1

itemsMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…