MCPcopy Create free account
hub / github.com/dask/dask / assert_eq

Function assert_eq

dask/array/utils.py:301–405  ·  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

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