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

Function test_map_overlap_multiarray

dask/array/tests/test_overlap.py:378–409  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

376
377@pytest.mark.xfail(da._array_expr_enabled(), reason="reshape needed") # type: ignore
378def test_map_overlap_multiarray():
379 # Same ndim, same numblocks, same chunks
380 x = da.arange(10, chunks=5)
381 y = da.arange(10, chunks=5)
382 z = da.map_overlap(lambda x, y: x + y, x, y, depth=1, boundary="none")
383 assert_eq(z, 2 * np.arange(10))
384
385 # Same ndim, same numblocks, different chunks
386 x = da.arange(10, chunks=(2, 3, 5))
387 y = da.arange(10, chunks=(5, 3, 2))
388 z = da.map_overlap(lambda x, y: x + y, x, y, depth=1, boundary="none")
389 assert z.chunks == ((2, 3, 3, 2),)
390 assert_eq(z, 2 * np.arange(10))
391
392 # Same ndim, different numblocks, different chunks
393 x = da.arange(10, chunks=(10,))
394 y = da.arange(10, chunks=(4, 4, 2))
395 z = da.map_overlap(lambda x, y: x + y, x, y, depth=1, boundary="none")
396 assert z.chunks == ((4, 4, 2),)
397 assert_eq(z, 2 * np.arange(10))
398
399 # Different ndim, different numblocks, different chunks
400 x = da.arange(10, chunks=(10,))
401 y = da.arange(10).reshape(1, 10).rechunk((1, (4, 4, 2)))
402 z = da.map_overlap(lambda x, y: x + y, x, y, depth=1, boundary="none")
403 assert z.chunks == ((1,), (4, 4, 2))
404 assert z.shape == (1, 10)
405 assert_eq(z, 2 * np.arange(10)[np.newaxis])
406
407 # Note: checks on arange equality in all of the above help ensure that
408 # trimming is applied appropriately to result chunks (i.e. results
409 # are not somehow shifted)
410
411
412def test_map_overlap_multiarray_defaults():

Callers

nothing calls this directly

Calls 5

assert_eqFunction · 0.90
reshapeMethod · 0.80
arangeMethod · 0.45
map_overlapMethod · 0.45
rechunkMethod · 0.45

Tested by

no test coverage detected