MCPcopy Index your code
hub / github.com/numpy/numpy / reduce

Method reduce

numpy/ma/core.py:6956–6987  ·  view source on GitHub ↗

Reduce target along the given axis.

(self, target, axis=np._NoValue)

Source from the content-addressed store, hash-verified

6954 return where(self.compare(a, b), a, b)
6955
6956 def reduce(self, target, axis=np._NoValue):
6957 "Reduce target along the given axis."
6958 target = narray(target, copy=None, subok=True)
6959 m = getmask(target)
6960
6961 if axis is np._NoValue and target.ndim > 1:
6962 name = self.__name__
6963 # 2017-05-06, Numpy 1.13.0: warn on axis default
6964 warnings.warn(
6965 f"In the future the default for ma.{name}.reduce will be axis=0, "
6966 f"not the current None, to match np.{name}.reduce. "
6967 "Explicitly pass 0 or None to silence this warning.",
6968 MaskedArrayFutureWarning, stacklevel=2)
6969 axis = None
6970
6971 if axis is not np._NoValue:
6972 kwargs = {'axis': axis}
6973 else:
6974 kwargs = {}
6975
6976 if m is nomask:
6977 t = self.f.reduce(target, **kwargs)
6978 else:
6979 target = target.filled(
6980 self.fill_value_func(target)).view(type(target))
6981 t = self.f.reduce(target, **kwargs)
6982 m = umath.logical_and.reduce(m, **kwargs)
6983 if hasattr(t, '_mask'):
6984 t._mask = m
6985 elif m:
6986 t = masked
6987 return t
6988
6989 def outer(self, a, b):
6990 "Return the function applied to the outer product of a and b."

Callers 15

_block_info_recursionFunction · 0.45
_wrapreductionFunction · 0.45
_wrapreduction_any_allFunction · 0.45
test_ufunc_add_reduceFunction · 0.45
test_add_promoter_reduceFunction · 0.45
test_multiply_reduceFunction · 0.45
test_reduceMethod · 0.45

Calls 3

getmaskFunction · 0.85
viewMethod · 0.45
filledMethod · 0.45