apply_over_axes(func, a, axes)
:None:None:`func`
is called as :None:None:`res = func(a, axis)`
, where :None:None:`axis`
is the first element of :None:None:`axes`
. The result :None:None:`res`
of the function call must have either the same dimensions as a
or one less dimension. If :None:None:`res`
has one less dimension than a
, a dimension is inserted before :None:None:`axis`
. The call to :None:None:`func`
is then repeated for each axis in :None:None:`axes`
, with :None:None:`res`
as the first argument.
This function is equivalent to tuple axis arguments to reorderable ufuncs with keepdims=True. Tuple axis arguments to ufuncs have been available since version 1.7.0.
This function must take two arguments, :None:None:`func(a, axis)`
.
Input array.
Axes over which :None:None:`func`
is applied; the elements must be integers.
The output array. The number of dimensions is the same as a
, but the shape can be different. This depends on whether :None:None:`func`
changes the shape of its output with respect to its input.
Apply a function repeatedly over multiple axes.
apply_along_axis
Apply a function to 1-D slices of an array along the given axis.
>>> a = np.arange(24).reshape(2,3,4)
... a array([[[ 0, 1, 2, 3], [ 4, 5, 6, 7], [ 8, 9, 10, 11]], [[12, 13, 14, 15], [16, 17, 18, 19], [20, 21, 22, 23]]])
Sum over axes 0 and 2. The result has same number of dimensions as the original array:
>>> np.apply_over_axes(np.sum, a, [0,2]) array([[[ 60], [ 92], [124]]])
Tuple axis arguments to ufuncs are equivalent:
>>> np.sum(a, axis=(0,2), keepdims=True) array([[[ 60], [ 92], [124]]])See :
The following pages refer to to this document either explicitly or contain code examples using this.
numpy.apply_along_axis
numpy.ma.extras.apply_along_axis
dask.array.routines.apply_over_axes
Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.
Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)
SVG is more flexible but power hungry; and does not scale well to 50 + nodes.
All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them