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

Function nearest

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

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