Execute the call behavior.
(self, a, *args, **kwargs)
| 926 | ufunc_fills[mufunc] = fill |
| 927 | |
| 928 | def __call__(self, a, *args, **kwargs): |
| 929 | """ |
| 930 | Execute the call behavior. |
| 931 | |
| 932 | """ |
| 933 | d = getdata(a) |
| 934 | # Deal with domain |
| 935 | if self.domain is not None: |
| 936 | # Case 1.1. : Domained function |
| 937 | # nans at masked positions cause RuntimeWarnings, even though |
| 938 | # they are masked. To avoid this we suppress warnings. |
| 939 | with np.errstate(divide='ignore', invalid='ignore'): |
| 940 | result = self.f(d, *args, **kwargs) |
| 941 | # Make a mask |
| 942 | m = ~umath.isfinite(result) |
| 943 | m |= self.domain(d) |
| 944 | m |= getmask(a) |
| 945 | else: |
| 946 | # Case 1.2. : Function without a domain |
| 947 | # Get the result and the mask |
| 948 | with np.errstate(divide='ignore', invalid='ignore'): |
| 949 | result = self.f(d, *args, **kwargs) |
| 950 | m = getmask(a) |
| 951 | |
| 952 | if not result.ndim: |
| 953 | # Case 2.1. : The result is scalarscalar |
| 954 | if m: |
| 955 | return masked |
| 956 | return result |
| 957 | |
| 958 | if m is not nomask: |
| 959 | # Case 2.2. The result is an array |
| 960 | # We need to fill the invalid data back w/ the input Now, |
| 961 | # that's plain silly: in C, we would just skip the element and |
| 962 | # keep the original, but we do have to do it that way in Python |
| 963 | |
| 964 | # In case result has a lower dtype than the inputs (as in |
| 965 | # equal) |
| 966 | try: |
| 967 | np.copyto(result, d, where=m) |
| 968 | except TypeError: |
| 969 | pass |
| 970 | # Transform to |
| 971 | masked_result = result.view(get_masked_subclass(a)) |
| 972 | masked_result._mask = m |
| 973 | masked_result._update_from(a) |
| 974 | return masked_result |
| 975 | |
| 976 | |
| 977 | class _MaskedBinaryOperation(_MaskedUFunc): |
nothing calls this directly
no test coverage detected