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

Function lazy_array_equiv

xarray/core/duck_array_ops.py:321–342  ·  view source on GitHub ↗

Like array_equal, but doesn't actually compare values. Returns True when arr1, arr2 identical or their dask tokens are equal. Returns False when shapes are not equal. Returns None when equality cannot determined: one or both of arr1, arr2 are numpy arrays; or their dask tokens are no

(arr1, arr2)

Source from the content-addressed store, hash-verified

319
320
321def lazy_array_equiv(arr1, arr2):
322 """Like array_equal, but doesn't actually compare values.
323 Returns True when arr1, arr2 identical or their dask tokens are equal.
324 Returns False when shapes are not equal.
325 Returns None when equality cannot determined: one or both of arr1, arr2 are numpy arrays;
326 or their dask tokens are not equal
327 """
328 if arr1 is arr2:
329 return True
330 arr1 = asarray(arr1)
331 arr2 = asarray(arr2)
332 if arr1.shape != arr2.shape:
333 return False
334 if dask_available and is_duck_dask_array(arr1) and is_duck_dask_array(arr2):
335 from dask.base import tokenize
336
337 # GH3068, GH4221
338 if tokenize(arr1) == tokenize(arr2):
339 return True
340 else:
341 return None
342 return None
343
344
345def allclose_or_equiv(arr1, arr2, rtol=1e-5, atol=1e-8):

Callers 3

allclose_or_equivFunction · 0.85
array_equivFunction · 0.85
array_notnull_equivFunction · 0.85

Calls 2

is_duck_dask_arrayFunction · 0.90
asarrayFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…