(This docstring will be overwritten)
(func, a, axes)
| 433 | |
| 434 | |
| 435 | def apply_over_axes(func, a, axes): |
| 436 | """ |
| 437 | (This docstring will be overwritten) |
| 438 | """ |
| 439 | val = asarray(a) |
| 440 | N = a.ndim |
| 441 | if array(axes).ndim == 0: |
| 442 | axes = (axes,) |
| 443 | for axis in axes: |
| 444 | if axis < 0: |
| 445 | axis = N + axis |
| 446 | args = (val, axis) |
| 447 | res = func(*args) |
| 448 | if res.ndim == val.ndim: |
| 449 | val = res |
| 450 | else: |
| 451 | res = ma.expand_dims(res, axis) |
| 452 | if res.ndim == val.ndim: |
| 453 | val = res |
| 454 | else: |
| 455 | raise ValueError("function is not returning " |
| 456 | "an array of the correct shape") |
| 457 | return val |
| 458 | |
| 459 | |
| 460 | if apply_over_axes.__doc__ is not None: |
searching dependent graphs…