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

Function test_map_blocks2

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

Source from the content-addressed store, hash-verified

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