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

Function nearest

dask/array/_array_expr/_overlap.py:248–270  ·  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

246
247
248def nearest(x, axis, depth):
249 """Each reflect each boundary value outwards
250
251 This mimics what the skimage.filters.gaussian_filter(... mode="nearest")
252 does.
253 """
254 left = (
255 (slice(None, None, None),) * axis
256 + (slice(0, 1),)
257 + (slice(None, None, None),) * (x.ndim - axis - 1)
258 )
259 right = (
260 (slice(None, None, None),) * axis
261 + (slice(-1, -2, -1),)
262 + (slice(None, None, None),) * (x.ndim - axis - 1)
263 )
264
265 l = repeat(x[left], depth, axis=axis)
266 r = repeat(x[right], depth, axis=axis)
267
268 l, r = _remove_overlap_boundaries(l, r, axis, depth)
269
270 return concatenate([l, x, r], axis=axis)
271
272
273def constant(x, axis, depth, value):

Callers 2

test_nearestFunction · 0.90
boundariesFunction · 0.70

Calls 3

repeatFunction · 0.90
concatenateFunction · 0.90

Tested by 1

test_nearestFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…