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

Function test_blockwise

dask/array/_array_expr/tests/test_collection.py:51–68  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

49
50@pytest.mark.array_expr
51def test_blockwise():
52 x = da.random.random((10, 10), chunks=(5, 5))
53 z = da.blockwise(operator.add, "ij", x, "ij", 100, None, dtype=x.dtype)
54 assert_eq(z, x.compute() + 100)
55
56 x = da.random.random((10, 10), chunks=(5, 5))
57 z = da.blockwise(operator.add, "ij", x, "ij", x, "ij", dtype=x.dtype)
58 expr = z.expr.optimize()
59 assert len(list(expr.find_operations(Rechunk))) == 0
60 assert_eq(z, x.compute() * 2)
61
62 # align
63 x = da.random.random((10, 10), chunks=(5, 5))
64 y = da.random.random((10, 10), chunks=(7, 3))
65 z = da.blockwise(operator.add, "ij", x, "ij", y, "ij", dtype=x.dtype)
66 expr = z.expr.optimize()
67 assert len(list(expr.find_operations(Rechunk))) > 0
68 assert_eq(z, x.compute() + y.compute())
69
70
71@pytest.mark.parametrize("func", ["min", "max", "sum", "prod", "mean", "any", "all"])

Callers

nothing calls this directly

Calls 5

assert_eqFunction · 0.90
find_operationsMethod · 0.80
randomMethod · 0.45
computeMethod · 0.45
optimizeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…