| 299 | |
| 300 | |
| 301 | def 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 " |