Replace values in `a` with NaN where `mask` is True. This differs from copyto in that it will deal with the case where `a` is a numpy scalar. Parameters ---------- a : ndarray or numpy scalar Array or numpy scalar some of whose values are to be replaced by val.
(a, val, mask)
| 113 | |
| 114 | |
| 115 | def _copyto(a, val, mask): |
| 116 | """ |
| 117 | Replace values in `a` with NaN where `mask` is True. This differs from |
| 118 | copyto in that it will deal with the case where `a` is a numpy scalar. |
| 119 | |
| 120 | Parameters |
| 121 | ---------- |
| 122 | a : ndarray or numpy scalar |
| 123 | Array or numpy scalar some of whose values are to be replaced |
| 124 | by val. |
| 125 | val : numpy scalar |
| 126 | Value used a replacement. |
| 127 | mask : ndarray, scalar |
| 128 | Boolean array. Where True the corresponding element of `a` is |
| 129 | replaced by `val`. Broadcasts. |
| 130 | |
| 131 | Returns |
| 132 | ------- |
| 133 | res : ndarray, scalar |
| 134 | Array with elements replaced or scalar `val`. |
| 135 | |
| 136 | """ |
| 137 | if isinstance(a, np.ndarray): |
| 138 | np.copyto(a, val, where=mask, casting='unsafe') |
| 139 | else: |
| 140 | a = a.dtype.type(val) |
| 141 | return a |
| 142 | |
| 143 | |
| 144 | def _remove_nan_1d(arr1d, second_arr1d=None, overwrite_input=False): |