MCPcopy Create free account
hub / github.com/numpy/numpy / reduce

Method reduce

numpy/ma/core.py:1057–1085  ·  view source on GitHub ↗

Reduce `target` along the given `axis`.

(self, target, axis=0, dtype=None)

Source from the content-addressed store, hash-verified

1055 return masked_result
1056
1057 def reduce(self, target, axis=0, dtype=None):
1058 """
1059 Reduce `target` along the given `axis`.
1060
1061 """
1062 tclass = get_masked_subclass(target)
1063 m = getmask(target)
1064 t = filled(target, self.filly)
1065 if t.shape == ():
1066 t = t.reshape(1)
1067 if m is not nomask:
1068 m = make_mask(m, copy=True)
1069 m.shape = (1,)
1070
1071 if m is nomask:
1072 tr = self.f.reduce(t, axis)
1073 mr = nomask
1074 else:
1075 tr = self.f.reduce(t, axis, dtype=dtype)
1076 mr = umath.logical_and.reduce(m, axis)
1077
1078 if not tr.shape:
1079 if mr:
1080 return masked
1081 else:
1082 return tr
1083 masked_tr = tr.view(tclass)
1084 masked_tr._mask = mr
1085 return masked_tr
1086
1087 def outer(self, a, b):
1088 """

Callers

nothing calls this directly

Calls 7

get_masked_subclassFunction · 0.85
getmaskFunction · 0.85
filledFunction · 0.85
make_maskFunction · 0.85
reshapeMethod · 0.80
reduceMethod · 0.45
viewMethod · 0.45

Tested by

no test coverage detected