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

Function test_map_blocks2

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

Source from the content-addressed store, hash-verified

1580
1581
1582def test_map_blocks2():
1583 x = np.arange(10, dtype="i8")
1584 d = from_array(x, chunks=(2,))
1585
1586 def func(block, block_id=None, c=0):
1587 return np.ones_like(block) * sum(block_id) + c
1588
1589 out = d.map_blocks(func, dtype="i8")
1590 expected = np.array([0, 0, 1, 1, 2, 2, 3, 3, 4, 4], dtype="i8")
1591
1592 assert_eq(out, expected)
1593 assert same_keys(d.map_blocks(func, dtype="i8"), out)
1594
1595 out = d.map_blocks(func, dtype="i8", c=1)
1596 expected = expected + 1
1597
1598 assert_eq(out, expected)
1599 assert same_keys(d.map_blocks(func, dtype="i8", c=1), out)
1600
1601
1602def test_map_blocks_block_info():

Callers

nothing calls this directly

Calls 5

from_arrayFunction · 0.90
assert_eqFunction · 0.90
same_keysFunction · 0.90
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…