MCPcopy
hub / github.com/dask/dask / assert_eq

Function assert_eq

dask/array/utils.py:299–403  ·  view source on GitHub ↗
(
    a,
    b,
    check_shape=True,
    check_graph=True,
    check_meta=True,
    check_chunks=True,
    check_ndim=True,
    check_type=True,
    check_dtype=True,
    equal_nan=True,
    scheduler="sync",
    **kwargs,
)

Source from the content-addressed store, hash-verified

297
298
299def assert_eq(
300 a,
301 b,
302 check_shape=True,
303 check_graph=True,
304 check_meta=True,
305 check_chunks=True,
306 check_ndim=True,
307 check_type=True,
308 check_dtype=True,
309 equal_nan=True,
310 scheduler="sync",
311 **kwargs,
312):
313 a_original = a
314 b_original = b
315
316 if isinstance(a, (list, int, float)):
317 a = np.array(a)
318 if isinstance(b, (list, int, float)):
319 b = np.array(b)
320
321 a, adt, a_meta, a_computed = _get_dt_meta_computed(
322 a,
323 check_shape=check_shape,
324 check_graph=check_graph,
325 check_chunks=check_chunks,
326 check_ndim=check_ndim,
327 scheduler=scheduler,
328 )
329 b, bdt, b_meta, b_computed = _get_dt_meta_computed(
330 b,
331 check_shape=check_shape,
332 check_graph=check_graph,
333 check_chunks=check_chunks,
334 check_ndim=check_ndim,
335 scheduler=scheduler,
336 )
337
338 if check_dtype and str(adt) != str(bdt):
339 raise AssertionError(f"a and b have different dtypes: (a: {adt}, b: {bdt})")
340
341 try:
342 assert (
343 a.shape == b.shape
344 ), f"a and b have different shapes (a: {a.shape}, b: {b.shape})"
345 if check_type:
346 _a = a if a.shape else a.item()
347 _b = b if b.shape else b.item()
348 assert type(_a) == type(
349 _b
350 ), f"a and b have different types (a: {type(_a)}, b: {type(_b)})"
351 if check_meta:
352 if hasattr(a, "_meta") and hasattr(b, "_meta"):
353 assert_eq(a._meta, b._meta)
354 if hasattr(a_original, "_meta"):
355 msg = (
356 f"compute()-ing 'a' changes its number of dimensions "

Callers 15

test_tsqrFunction · 0.90
test_tsqr_uncertainFunction · 0.90
test_sfqrFunction · 0.90
test_lstsqFunction · 0.90
test_choleskyFunction · 0.90
test_arr_likeFunction · 0.90
test_arr_like_shapeFunction · 0.90
test_linspaceFunction · 0.90
test_arangeFunction · 0.90
test_arange_dtype_inferFunction · 0.90

Calls 3

_get_dt_meta_computedFunction · 0.85
allcloseFunction · 0.70
allMethod · 0.45

Tested by 15

test_tsqrFunction · 0.72
test_tsqr_uncertainFunction · 0.72
test_sfqrFunction · 0.72
test_lstsqFunction · 0.72
test_choleskyFunction · 0.72
test_arr_likeFunction · 0.72
test_arr_like_shapeFunction · 0.72
test_linspaceFunction · 0.72
test_arangeFunction · 0.72
test_arange_dtype_inferFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…