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

Function equivalent_attrs

xarray/structure/merge.py:617–633  ·  view source on GitHub ↗

Check if two attribute values are equivalent. Returns False if the comparison raises ValueError or TypeError. This handles cases like numpy arrays with ambiguous truth values and xarray Datasets which can't be directly converted to numpy arrays. Since equivalent() now handles non-b

(a: Any, b: Any)

Source from the content-addressed store, hash-verified

615
616
617def equivalent_attrs(a: Any, b: Any) -> bool:
618 """Check if two attribute values are equivalent.
619
620 Returns False if the comparison raises ValueError or TypeError.
621 This handles cases like numpy arrays with ambiguous truth values
622 and xarray Datasets which can't be directly converted to numpy arrays.
623
624 Since equivalent() now handles non-boolean returns by returning False,
625 this wrapper mainly catches exceptions from comparisons that can't be
626 evaluated at all.
627 """
628 try:
629 return equivalent(a, b)
630 except (ValueError, TypeError):
631 # These exceptions indicate the comparison is truly ambiguous
632 # (e.g., nested numpy arrays that would raise "ambiguous truth value")
633 return False
634
635
636def merge_attrs(variable_attrs, combine_attrs, context=None):

Callers 1

merge_attrsFunction · 0.85

Calls 1

equivalentFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…