Execute the call behavior.
(self, a, b, *args, **kwargs)
| 1008 | ufunc_fills[mbfunc] = (fillx, filly) |
| 1009 | |
| 1010 | def __call__(self, a, b, *args, **kwargs): |
| 1011 | """ |
| 1012 | Execute the call behavior. |
| 1013 | |
| 1014 | """ |
| 1015 | # Get the data, as ndarray |
| 1016 | (da, db) = (getdata(a), getdata(b)) |
| 1017 | # Get the result |
| 1018 | with np.errstate(): |
| 1019 | np.seterr(divide='ignore', invalid='ignore') |
| 1020 | result = self.f(da, db, *args, **kwargs) |
| 1021 | # Get the mask for the result |
| 1022 | (ma, mb) = (getmask(a), getmask(b)) |
| 1023 | if ma is nomask: |
| 1024 | if mb is nomask: |
| 1025 | m = nomask |
| 1026 | else: |
| 1027 | m = umath.logical_or(getmaskarray(a), mb) |
| 1028 | elif mb is nomask: |
| 1029 | m = umath.logical_or(ma, getmaskarray(b)) |
| 1030 | else: |
| 1031 | m = umath.logical_or(ma, mb) |
| 1032 | |
| 1033 | # Case 1. : scalar |
| 1034 | if not result.ndim: |
| 1035 | if m: |
| 1036 | return masked |
| 1037 | return result |
| 1038 | |
| 1039 | # Case 2. : array |
| 1040 | # Revert result to da where masked |
| 1041 | if m is not nomask and m.any(): |
| 1042 | # any errors, just abort; impossible to guarantee masked values |
| 1043 | try: |
| 1044 | np.copyto(result, da, casting='unsafe', where=m) |
| 1045 | except Exception: |
| 1046 | pass |
| 1047 | |
| 1048 | # Transforms to a (subclass of) MaskedArray |
| 1049 | masked_result = result.view(get_masked_subclass(a, b)) |
| 1050 | masked_result._mask = m |
| 1051 | if isinstance(a, MaskedArray): |
| 1052 | masked_result._update_from(a) |
| 1053 | elif isinstance(b, MaskedArray): |
| 1054 | masked_result._update_from(b) |
| 1055 | return masked_result |
| 1056 | |
| 1057 | def reduce(self, target, axis=0, dtype=None): |
| 1058 | """ |
nothing calls this directly
no test coverage detected