Add boundary conditions to an array before overlapping See Also -------- periodic constant
(x, depth=None, kind=None)
| 298 | |
| 299 | |
| 300 | def boundaries(x, depth=None, kind=None): |
| 301 | """Add boundary conditions to an array before overlapping |
| 302 | |
| 303 | See Also |
| 304 | -------- |
| 305 | periodic |
| 306 | constant |
| 307 | """ |
| 308 | if not isinstance(kind, dict): |
| 309 | kind = dict.fromkeys(range(x.ndim), kind) |
| 310 | if not isinstance(depth, dict): |
| 311 | depth = dict.fromkeys(range(x.ndim), depth) |
| 312 | |
| 313 | for i in range(x.ndim): |
| 314 | d = depth.get(i, 0) |
| 315 | if d == 0: |
| 316 | continue |
| 317 | |
| 318 | this_kind = kind.get(i, "none") |
| 319 | if this_kind == "none": |
| 320 | continue |
| 321 | elif this_kind == "periodic": |
| 322 | x = periodic(x, i, d) |
| 323 | elif this_kind == "reflect": |
| 324 | x = reflect(x, i, d) |
| 325 | elif this_kind == "nearest": |
| 326 | x = nearest(x, i, d) |
| 327 | elif i in kind: |
| 328 | x = constant(x, i, d, kind[i]) |
| 329 | |
| 330 | return x |
| 331 | |
| 332 | |
| 333 | def ensure_minimum_chunksize(size, chunks): |
searching dependent graphs…