MCPcopy
hub / github.com/dask/dask / nearest

Function nearest

dask/array/overlap.py:234–256  ·  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

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

Callers 1

boundariesFunction · 0.70

Calls 3

repeatFunction · 0.90
concatenateFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…