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