()
| 1552 | |
| 1553 | |
| 1554 | def 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 | |
| 1582 | def test_map_blocks2(): |
nothing calls this directly
no test coverage detected
searching dependent graphs…