Copy a slice of an array around to its other side Useful to create periodic boundary conditions for overlap
(x, axis, depth)
| 179 | |
| 180 | |
| 181 | def periodic(x, axis, depth): |
| 182 | """Copy a slice of an array around to its other side |
| 183 | |
| 184 | Useful to create periodic boundary conditions for overlap |
| 185 | """ |
| 186 | |
| 187 | left = ( |
| 188 | (slice(None, None, None),) * axis |
| 189 | + (slice(0, depth),) |
| 190 | + (slice(None, None, None),) * (x.ndim - axis - 1) |
| 191 | ) |
| 192 | right = ( |
| 193 | (slice(None, None, None),) * axis |
| 194 | + (slice(-depth, None),) |
| 195 | + (slice(None, None, None),) * (x.ndim - axis - 1) |
| 196 | ) |
| 197 | l = x[left] |
| 198 | r = x[right] |
| 199 | |
| 200 | l, r = _remove_overlap_boundaries(l, r, axis, depth) |
| 201 | |
| 202 | return concatenate([r, x, l], axis=axis) |
| 203 | |
| 204 | |
| 205 | def reflect(x, axis, depth): |
no test coverage detected