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

Function test_blockwise_concatenate

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

Source from the content-addressed store, hash-verified

4007
4008
4009def test_blockwise_concatenate():
4010 x = da.ones((4, 4, 4), chunks=(2, 2, 2))
4011 y = da.ones((4, 4), chunks=(2, 2))
4012
4013 def f(a, b):
4014 assert isinstance(a, np.ndarray)
4015 assert isinstance(b, np.ndarray)
4016
4017 assert a.shape == (2, 4, 4)
4018 assert b.shape == (4, 4)
4019
4020 return (a + b).sum(axis=(1, 2))
4021
4022 z = da.blockwise(f, "i", x, "ijk", y, "jk", concatenate=True, dtype=x.dtype)
4023 assert_eq(z, np.ones(4) * 32)
4024
4025 z = da.blockwise(add, "ij", y, "ij", y, "ij", concatenate=True, dtype=x.dtype)
4026 assert_eq(z, np.ones((4, 4)) * 2)
4027
4028 def f(a, b, c):
4029 assert isinstance(a, np.ndarray)
4030 assert isinstance(b, np.ndarray)
4031 assert isinstance(c, np.ndarray)
4032
4033 assert a.shape == (4, 2, 4)
4034 assert b.shape == (4, 4)
4035 assert c.shape == (4, 2)
4036
4037 return np.ones(2)
4038
4039 z = da.blockwise(
4040 f, "j", x, "ijk", y, "ki", y, "ij", concatenate=True, dtype=x.dtype
4041 )
4042 assert_eq(z, np.ones(4), check_shape=False)
4043
4044
4045def test_common_blockdim():

Callers

nothing calls this directly

Calls 2

assert_eqFunction · 0.90
onesMethod · 0.45

Tested by

no test coverage detected