Reflect boundaries of array on the same side This is the converse of ``periodic``
(x, axis, depth)
| 203 | |
| 204 | |
| 205 | def 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 | |
| 235 | def nearest(x, axis, depth): |
no test coverage detected