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

Function reflect

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

203
204
205def reflect(x, axis, depth):
206 """Reflect boundaries of array on the same side
207
208 This is the converse of ``periodic``
209 """
210 if depth == 1:
211 left = (
212 (slice(None, None, None),) * axis
213 + (slice(0, 1),)
214 + (slice(None, None, None),) * (x.ndim - axis - 1)
215 )
216 else:
217 left = (
218 (slice(None, None, None),) * axis
219 + (slice(depth - 1, None, -1),)
220 + (slice(None, None, None),) * (x.ndim - axis - 1)
221 )
222 right = (
223 (slice(None, None, None),) * axis
224 + (slice(-1, -depth - 1, -1),)
225 + (slice(None, None, None),) * (x.ndim - axis - 1)
226 )
227 l = x[left]
228 r = x[right]
229
230 l, r = _remove_overlap_boundaries(l, r, axis, depth)
231
232 return concatenate([l, x, r], axis=axis)
233
234
235def nearest(x, axis, depth):

Callers 1

boundariesFunction · 0.70

Calls 2

concatenateFunction · 0.90

Tested by

no test coverage detected