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