|
40 | 40 |
|
41 | 41 | import sdc |
42 | 42 | from sdc.utilities.sdc_typing_utils import TypeChecker |
43 | | -from sdc.str_arr_ext import (StringArrayType, pre_alloc_string_array, get_utf8_size) |
| 43 | +from sdc.str_arr_ext import (StringArrayType, pre_alloc_string_array, get_utf8_size, str_arr_is_na) |
44 | 44 | from sdc.utilities.utils import sdc_overload, sdc_register_jitable |
45 | 45 |
|
46 | 46 |
|
47 | 47 | def astype(self, dtype): |
48 | 48 | pass |
49 | 49 |
|
50 | 50 |
|
| 51 | +def isnan(self): |
| 52 | + pass |
| 53 | + |
| 54 | + |
| 55 | +def notnan(self): |
| 56 | + pass |
| 57 | + |
| 58 | + |
51 | 59 | def sum(self): |
52 | 60 | pass |
53 | 61 |
|
@@ -117,6 +125,82 @@ def sdc_astype_number_impl(self, dtype): |
117 | 125 | ty_checker.raise_exc(self.dtype, 'str or type', 'self.dtype') |
118 | 126 |
|
119 | 127 |
|
| 128 | +@sdc_overload(notnan) |
| 129 | +def sdc_isnan_overload(self): |
| 130 | + """ |
| 131 | + Intel Scalable Dataframe Compiler Developer Guide |
| 132 | + ************************************************* |
| 133 | + Parallel replacement of numpy.notnan. |
| 134 | + .. only:: developer |
| 135 | + Test: python -m sdc.runtests sdc.tests.test_sdc_numpy -k notnan |
| 136 | + """ |
| 137 | + |
| 138 | + if not isinstance(self, types.Array): |
| 139 | + return None |
| 140 | + |
| 141 | + dtype = self.dtype |
| 142 | + isnan = get_isnan(dtype) |
| 143 | + if isinstance(dtype, types.Integer): |
| 144 | + def sdc_notnan_int_impl(self): |
| 145 | + length = len(self) |
| 146 | + res = numpy.ones(shape=length, dtype=numpy.bool_) |
| 147 | + |
| 148 | + return res |
| 149 | + |
| 150 | + return sdc_notnan_int_impl |
| 151 | + |
| 152 | + if isinstance(dtype, types.Float): |
| 153 | + def sdc_notnan_float_impl(self): |
| 154 | + length = len(self) |
| 155 | + res = numpy.empty(shape=length, dtype=numpy.bool_) |
| 156 | + for i in prange(length): |
| 157 | + res[i] = not isnan(self[i]) |
| 158 | + |
| 159 | + return res |
| 160 | + |
| 161 | + return sdc_notnan_float_impl |
| 162 | + |
| 163 | + ty_checker.raise_exc(dtype, 'int or float', 'self.dtype') |
| 164 | + |
| 165 | + |
| 166 | +@sdc_overload(isnan) |
| 167 | +def sdc_isnan_overload(self): |
| 168 | + """ |
| 169 | + Intel Scalable Dataframe Compiler Developer Guide |
| 170 | + ************************************************* |
| 171 | + Parallel replacement of numpy.isnan. |
| 172 | + .. only:: developer |
| 173 | + Test: python -m sdc.runtests sdc.tests.test_sdc_numpy -k isnan |
| 174 | + """ |
| 175 | + |
| 176 | + if not isinstance(self, types.Array): |
| 177 | + return None |
| 178 | + |
| 179 | + dtype = self.dtype |
| 180 | + isnan = get_isnan(dtype) |
| 181 | + if isinstance(dtype, types.Integer): |
| 182 | + def sdc_isnan_int_impl(self): |
| 183 | + length = len(self) |
| 184 | + res = numpy.zeros(shape=length, dtype=numpy.bool_) |
| 185 | + |
| 186 | + return res |
| 187 | + |
| 188 | + return sdc_isnan_int_impl |
| 189 | + |
| 190 | + if isinstance(dtype, types.Float): |
| 191 | + def sdc_isnan_float_impl(self): |
| 192 | + length = len(self) |
| 193 | + res = numpy.empty(shape=length, dtype=numpy.bool_) |
| 194 | + for i in prange(length): |
| 195 | + res[i] = isnan(self[i]) |
| 196 | + |
| 197 | + return res |
| 198 | + |
| 199 | + return sdc_isnan_float_impl |
| 200 | + |
| 201 | + ty_checker.raise_exc(dtype, 'int or float', 'self.dtype') |
| 202 | + |
| 203 | + |
120 | 204 | @sdc_overload(sum) |
121 | 205 | def sdc_sum_overload(self): |
122 | 206 | """ |
|
0 commit comments