def _ireduce_ufunc_all_axes(arrays, ufunc, **kwargs):
"""
Reduction operation for arrays, over all axes.
Parameters
----------
arrays : iterable
Arrays to be reduced.
ufunc : numpy.ufunc
Binary universal function. Must have a signature of the form ufunc(x1, x2, ...)
kwargs
Keyword arguments are passed to ``ufunc``. The ``out`` parameter is ignored.
Yields
------
reduced : scalar
"""
arrays = iter(arrays)
first = next(arrays)
kwargs['axis'] = None
kwargs.pop('out', None) # Remove the out-parameter if provided.
axis_reduce = partial(ufunc.reduce, **kwargs)
accumulator = axis_reduce(first)
yield accumulator
for array in arrays:
accumulator = axis_reduce([accumulator, axis_reduce(array)])
yield accumulator
评论列表
文章目录