Each reflect each boundary value outwards This mimics what the skimage.filters.gaussian_filter(... mode="nearest") does.
(x, axis, depth)
| 233 | |
| 234 | |
| 235 | def nearest(x, axis, depth): |
| 236 | """Each reflect each boundary value outwards |
| 237 | |
| 238 | This mimics what the skimage.filters.gaussian_filter(... mode="nearest") |
| 239 | does. |
| 240 | """ |
| 241 | left = ( |
| 242 | (slice(None, None, None),) * axis |
| 243 | + (slice(0, 1),) |
| 244 | + (slice(None, None, None),) * (x.ndim - axis - 1) |
| 245 | ) |
| 246 | right = ( |
| 247 | (slice(None, None, None),) * axis |
| 248 | + (slice(-1, -2, -1),) |
| 249 | + (slice(None, None, None),) * (x.ndim - axis - 1) |
| 250 | ) |
| 251 | |
| 252 | l = repeat(x[left], depth, axis=axis) |
| 253 | r = repeat(x[right], depth, axis=axis) |
| 254 | |
| 255 | l, r = _remove_overlap_boundaries(l, r, axis, depth) |
| 256 | |
| 257 | return concatenate([l, x, r], axis=axis) |
| 258 | |
| 259 | |
| 260 | def constant(x, axis, depth, value): |
no test coverage detected