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

Function test_map_blocks2

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

Source from the content-addressed store, hash-verified

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