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

Class _extrema_operation

numpy/ma/core.py:6937–7003  ·  view source on GitHub ↗

Generic class for maximum/minimum functions. .. note:: This is the base class for `_maximum_operation` and `_minimum_operation`.

Source from the content-addressed store, hash-verified

6935
6936
6937class _extrema_operation(_MaskedUFunc):
6938 """
6939 Generic class for maximum/minimum functions.
6940
6941 .. note::
6942 This is the base class for `_maximum_operation` and
6943 `_minimum_operation`.
6944
6945 """
6946 def __init__(self, ufunc, compare, fill_value):
6947 super().__init__(ufunc)
6948 self.compare = compare
6949 self.fill_value_func = fill_value
6950
6951 def __call__(self, a, b):
6952 "Executes the call behavior."
6953
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."
6991 ma = getmask(a)
6992 mb = getmask(b)
6993 if ma is nomask and mb is nomask:
6994 m = nomask

Callers 1

core.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…