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

Function pad_udf

dask/array/creation.py:1222–1252  ·  view source on GitHub ↗

Helper function for padding boundaries with a user defined function. In cases where the padding requires a custom user defined function be applied to the array, this function assists in the prepping and application of this function to the Dask Array to construct the desired bou

(array, pad_width, mode, **kwargs)

Source from the content-addressed store, hash-verified

1220
1221
1222def pad_udf(array, pad_width, mode, **kwargs):
1223 """
1224 Helper function for padding boundaries with a user defined function.
1225
1226 In cases where the padding requires a custom user defined function be
1227 applied to the array, this function assists in the prepping and
1228 application of this function to the Dask Array to construct the desired
1229 boundaries.
1230 """
1231
1232 result = pad_edge(array, pad_width, "constant", constant_values=0)
1233
1234 chunks = result.chunks
1235 for d in range(result.ndim):
1236 result = result.rechunk(
1237 chunks[:d] + (result.shape[d : d + 1],) + chunks[d + 1 :]
1238 )
1239
1240 result = result.map_blocks(
1241 wrapped_pad_func,
1242 token="pad",
1243 dtype=result.dtype,
1244 pad_func=mode,
1245 iaxis_pad_width=pad_width[d],
1246 iaxis=d,
1247 pad_func_kwargs=kwargs,
1248 )
1249
1250 result = result.rechunk(chunks)
1251
1252 return result
1253
1254
1255@derived_from(np)

Callers 1

padFunction · 0.85

Calls 3

pad_edgeFunction · 0.85
rechunkMethod · 0.45
map_blocksMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…