MCPcopy
hub / github.com/dask/dask / test_pad_udf

Function test_pad_udf

dask/array/tests/test_creation.py:978–996  ·  view source on GitHub ↗
(kwargs)

Source from the content-addressed store, hash-verified

976
977@pytest.mark.parametrize("kwargs", [{}, {"scaler": 2}])
978def test_pad_udf(kwargs):
979 def udf_pad(vector, pad_width, iaxis, inner_kwargs):
980 assert kwargs == inner_kwargs
981 scaler = inner_kwargs.get("scaler", 1)
982 vector[: pad_width[0]] = -scaler * pad_width[0]
983 vector[-pad_width[1] :] = scaler * pad_width[1]
984 return vector
985
986 shape = (10, 11)
987 chunks = (4, 5)
988 pad_width = ((1, 2), (2, 3))
989
990 np_a = np.random.random(shape)
991 da_a = da.from_array(np_a, chunks=chunks)
992
993 np_r = np.pad(np_a, pad_width, udf_pad, **kwargs)
994 da_r = da.pad(da_a, pad_width, udf_pad, **kwargs)
995
996 assert_eq(np_r, da_r)
997
998
999def test_pad_constant_chunksizes():

Callers

nothing calls this directly

Calls 2

assert_eqFunction · 0.90
randomMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…