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

Function reflect

dask/array/_array_expr/_overlap.py:219–246  ·  view source on GitHub ↗

Reflect boundaries of array on the same side This is the converse of ``periodic``

(x, axis, depth)

Source from the content-addressed store, hash-verified

217
218
219def reflect(x, axis, depth):
220 """Reflect boundaries of array on the same side
221
222 This is the converse of ``periodic``
223 """
224 if depth == 1:
225 left = (
226 (slice(None, None, None),) * axis
227 + (slice(0, 1),)
228 + (slice(None, None, None),) * (x.ndim - axis - 1)
229 )
230 else:
231 left = (
232 (slice(None, None, None),) * axis
233 + (slice(depth - 1, None, -1),)
234 + (slice(None, None, None),) * (x.ndim - axis - 1)
235 )
236 right = (
237 (slice(None, None, None),) * axis
238 + (slice(-1, -depth - 1, -1),)
239 + (slice(None, None, None),) * (x.ndim - axis - 1)
240 )
241 l = x[left]
242 r = x[right]
243
244 l, r = _remove_overlap_boundaries(l, r, axis, depth)
245
246 return concatenate([l, x, r], axis=axis)
247
248
249def nearest(x, axis, depth):

Callers 2

test_reflectFunction · 0.90
boundariesFunction · 0.70

Calls 2

concatenateFunction · 0.90

Tested by 1

test_reflectFunction · 0.72