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

Function nearest

dask/array/overlap.py:235–257  ·  view source on GitHub ↗

Each reflect each boundary value outwards This mimics what the skimage.filters.gaussian_filter(... mode="nearest") does.

(x, axis, depth)

Source from the content-addressed store, hash-verified

233
234
235def nearest(x, axis, depth):
236 """Each reflect each boundary value outwards
237
238 This mimics what the skimage.filters.gaussian_filter(... mode="nearest")
239 does.
240 """
241 left = (
242 (slice(None, None, None),) * axis
243 + (slice(0, 1),)
244 + (slice(None, None, None),) * (x.ndim - axis - 1)
245 )
246 right = (
247 (slice(None, None, None),) * axis
248 + (slice(-1, -2, -1),)
249 + (slice(None, None, None),) * (x.ndim - axis - 1)
250 )
251
252 l = repeat(x[left], depth, axis=axis)
253 r = repeat(x[right], depth, axis=axis)
254
255 l, r = _remove_overlap_boundaries(l, r, axis, depth)
256
257 return concatenate([l, x, r], axis=axis)
258
259
260def constant(x, axis, depth, value):

Callers 1

boundariesFunction · 0.70

Calls 3

repeatFunction · 0.90
concatenateFunction · 0.90

Tested by

no test coverage detected