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

Function dict_equiv

xarray/core/utils.py:410–434  ·  view source on GitHub ↗

Test equivalence of two dict-like objects. If any of the values are numpy arrays, compare them correctly. Parameters ---------- first, second : dict-like Dictionaries to compare for equality compat : function, optional Binary operator to determine if two values a

(
    first: Mapping[K, V],
    second: Mapping[K, V],
    compat: Callable[[V, V], bool] = equivalent,
)

Source from the content-addressed store, hash-verified

408
409
410def dict_equiv(
411 first: Mapping[K, V],
412 second: Mapping[K, V],
413 compat: Callable[[V, V], bool] = equivalent,
414) -> bool:
415 """Test equivalence of two dict-like objects. If any of the values are
416 numpy arrays, compare them correctly.
417
418 Parameters
419 ----------
420 first, second : dict-like
421 Dictionaries to compare for equality
422 compat : function, optional
423 Binary operator to determine if two values are compatible. By default,
424 checks for equivalence.
425
426 Returns
427 -------
428 equals : bool
429 True if the dictionaries are equal
430 """
431 for k in first:
432 if k not in second or not compat(first[k], second[k]):
433 return False
434 return all(k in first for k in second)
435
436
437def compat_dict_intersection(

Callers 2

merge_collectedFunction · 0.90
merge_attrsFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…