MCPcopy Index your code
hub / github.com/dask/dask / test_map_blocks

Function test_map_blocks

dask/array/tests/test_array_core.py:1554–1579  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1552
1553
1554def test_map_blocks():
1555 x = np.arange(400).reshape((20, 20))
1556 d = from_array(x, chunks=(7, 7))
1557
1558 e = d.map_blocks(inc, dtype=d.dtype)
1559
1560 assert d.chunks == e.chunks
1561 assert_eq(e, x + 1)
1562
1563 e = d.map_blocks(inc, token="increment")
1564 assert e.name.startswith("increment-")
1565
1566 assert d.map_blocks(inc, token="foo").name != d.map_blocks(dec, token="foo").name
1567
1568 d = from_array(x, chunks=(10, 10))
1569 e = d.map_blocks(lambda x: x[::2, ::2], chunks=(5, 5), dtype=d.dtype)
1570
1571 assert e.chunks == ((5, 5), (5, 5))
1572 assert_eq(e, x[::2, ::2])
1573
1574 d = from_array(x, chunks=(8, 8))
1575 e = d.map_blocks(
1576 lambda x: x[::2, ::2], chunks=((4, 4, 2), (4, 4, 2)), dtype=d.dtype
1577 )
1578
1579 assert_eq(e, x[::2, ::2])
1580
1581
1582def test_map_blocks2():

Callers

nothing calls this directly

Calls 5

from_arrayFunction · 0.90
assert_eqFunction · 0.90
reshapeMethod · 0.80
arangeMethod · 0.45
map_blocksMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…