MCPcopy
hub / github.com/numpy/numpy / __call__

Method __call__

numpy/ma/core.py:1062–1107  ·  view source on GitHub ↗

Execute the call behavior.

(self, a, b, *args, **kwargs)

Source from the content-addressed store, hash-verified

1060 ufunc_fills[mbfunc] = (fillx, filly)
1061
1062 def __call__(self, a, b, *args, **kwargs):
1063 """
1064 Execute the call behavior.
1065
1066 """
1067 # Get the data, as ndarray
1068 (da, db) = (getdata(a), getdata(b))
1069 # Get the result
1070 with np.errstate():
1071 np.seterr(divide='ignore', invalid='ignore')
1072 result = self.f(da, db, *args, **kwargs)
1073 # Get the mask for the result
1074 (ma, mb) = (getmask(a), getmask(b))
1075 if ma is nomask:
1076 if mb is nomask:
1077 m = nomask
1078 else:
1079 m = umath.logical_or(getmaskarray(a), mb)
1080 elif mb is nomask:
1081 m = umath.logical_or(ma, getmaskarray(b))
1082 else:
1083 m = umath.logical_or(ma, mb)
1084
1085 # Case 1. : scalar
1086 if not result.ndim:
1087 if m:
1088 return masked
1089 return result
1090
1091 # Case 2. : array
1092 # Revert result to da where masked
1093 if m is not nomask and m.any():
1094 # any errors, just abort; impossible to guarantee masked values
1095 try:
1096 np.copyto(result, da, casting='unsafe', where=m)
1097 except Exception:
1098 pass
1099
1100 # Transforms to a (subclass of) MaskedArray
1101 masked_result = result.view(get_masked_subclass(a, b))
1102 masked_result._mask = m
1103 if isinstance(a, MaskedArray):
1104 masked_result._update_from(a)
1105 elif isinstance(b, MaskedArray):
1106 masked_result._update_from(b)
1107 return masked_result
1108
1109 def reduce(self, target, axis=0, dtype=None):
1110 """

Callers

nothing calls this directly

Calls 8

getdataFunction · 0.85
getmaskFunction · 0.85
getmaskarrayFunction · 0.85
get_masked_subclassFunction · 0.85
_update_fromMethod · 0.80
fMethod · 0.45
anyMethod · 0.45
viewMethod · 0.45

Tested by

no test coverage detected