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