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