MCPcopy
hub / github.com/numpy/numpy / apply_over_axes

Function apply_over_axes

numpy/ma/extras.py:435–457  ·  view source on GitHub ↗

(This docstring will be overwritten)

(func, a, axes)

Source from the content-addressed store, hash-verified

433
434
435def 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
460if apply_over_axes.__doc__ is not None:

Callers 1

test_basicMethod · 0.90

Calls 3

asarrayFunction · 0.70
arrayFunction · 0.70
funcFunction · 0.50

Tested by 1

test_basicMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…