Execute the call behavior.
(self, a, b, *args, **kwargs)
| 1205 | ufunc_fills[dbfunc] = (fillx, filly) |
| 1206 | |
| 1207 | def __call__(self, a, b, *args, **kwargs): |
| 1208 | "Execute the call behavior." |
| 1209 | # Get the data |
| 1210 | (da, db) = (getdata(a), getdata(b)) |
| 1211 | # Get the result |
| 1212 | with np.errstate(divide='ignore', invalid='ignore'): |
| 1213 | result = self.f(da, db, *args, **kwargs) |
| 1214 | # Get the mask as a combination of the source masks and invalid |
| 1215 | m = ~umath.isfinite(result) |
| 1216 | m |= getmask(a) |
| 1217 | m |= getmask(b) |
| 1218 | # Apply the domain |
| 1219 | domain = ufunc_domain.get(self.f, None) |
| 1220 | if domain is not None: |
| 1221 | m |= domain(da, db) |
| 1222 | # Take care of the scalar case first |
| 1223 | if not m.ndim: |
| 1224 | if m: |
| 1225 | return masked |
| 1226 | else: |
| 1227 | return result |
| 1228 | # When the mask is True, put back da if possible |
| 1229 | # any errors, just abort; impossible to guarantee masked values |
| 1230 | try: |
| 1231 | np.copyto(result, 0, casting='unsafe', where=m) |
| 1232 | # avoid using "*" since this may be overlaid |
| 1233 | masked_da = umath.multiply(m, da) |
| 1234 | # only add back if it can be cast safely |
| 1235 | if np.can_cast(masked_da.dtype, result.dtype, casting='safe'): |
| 1236 | result += masked_da |
| 1237 | except Exception: |
| 1238 | pass |
| 1239 | |
| 1240 | # Transforms to a (subclass of) MaskedArray |
| 1241 | masked_result = result.view(get_masked_subclass(a, b)) |
| 1242 | masked_result._mask = m |
| 1243 | if isinstance(a, MaskedArray): |
| 1244 | masked_result._update_from(a) |
| 1245 | elif isinstance(b, MaskedArray): |
| 1246 | masked_result._update_from(b) |
| 1247 | return masked_result |
| 1248 | |
| 1249 | |
| 1250 | # Unary ufuncs |
nothing calls this directly
no test coverage detected