Execute the call behavior.
(self, a, *args, **kwargs)
| 978 | ufunc_fills[mufunc] = fill |
| 979 | |
| 980 | def __call__(self, a, *args, **kwargs): |
| 981 | """ |
| 982 | Execute the call behavior. |
| 983 | |
| 984 | """ |
| 985 | d = getdata(a) |
| 986 | # Deal with domain |
| 987 | if self.domain is not None: |
| 988 | # Case 1.1. : Domained function |
| 989 | # nans at masked positions cause RuntimeWarnings, even though |
| 990 | # they are masked. To avoid this we suppress warnings. |
| 991 | with np.errstate(divide='ignore', invalid='ignore'): |
| 992 | result = self.f(d, *args, **kwargs) |
| 993 | # Make a mask |
| 994 | m = ~umath.isfinite(result) |
| 995 | m |= self.domain(d) |
| 996 | m |= getmask(a) |
| 997 | else: |
| 998 | # Case 1.2. : Function without a domain |
| 999 | # Get the result and the mask |
| 1000 | with np.errstate(divide='ignore', invalid='ignore'): |
| 1001 | result = self.f(d, *args, **kwargs) |
| 1002 | m = getmask(a) |
| 1003 | |
| 1004 | if not result.ndim: |
| 1005 | # Case 2.1. : The result is scalarscalar |
| 1006 | if m: |
| 1007 | return masked |
| 1008 | return result |
| 1009 | |
| 1010 | if m is not nomask: |
| 1011 | # Case 2.2. The result is an array |
| 1012 | # We need to fill the invalid data back w/ the input Now, |
| 1013 | # that's plain silly: in C, we would just skip the element and |
| 1014 | # keep the original, but we do have to do it that way in Python |
| 1015 | |
| 1016 | # In case result has a lower dtype than the inputs (as in |
| 1017 | # equal) |
| 1018 | try: |
| 1019 | np.copyto(result, d, where=m) |
| 1020 | except TypeError: |
| 1021 | pass |
| 1022 | # Transform to |
| 1023 | masked_result = result.view(get_masked_subclass(a)) |
| 1024 | masked_result._mask = m |
| 1025 | masked_result._update_from(a) |
| 1026 | return masked_result |
| 1027 | |
| 1028 | |
| 1029 | class _MaskedBinaryOperation(_MaskedUFunc): |
nothing calls this directly
no test coverage detected