|
41 | 41 | from numba.core.datamodel import register_default, StructModel |
42 | 42 | from numba.core.typing.templates import signature, infer_global, AbstractTemplate |
43 | 43 |
|
44 | | -from sdc.config import config_pipeline_hpat_default |
45 | | - |
46 | 44 |
|
47 | 45 | class DataFrameTypeIterator(types.SimpleIteratorType): |
48 | 46 | """ |
@@ -111,23 +109,23 @@ def iterator_type(self): |
111 | 109 | return DataFrameTypeIterator(self) |
112 | 110 |
|
113 | 111 |
|
114 | | -if not config_pipeline_hpat_default: |
115 | | - @register_model(DataFrameType) |
116 | | - class DataFrameTypeModel(StructModel): |
117 | | - """ |
118 | | - Model for DataFrameType type |
119 | | - All members must be the same as main type for this model |
| 112 | +@register_model(DataFrameType) |
| 113 | +class DataFrameTypeModel(StructModel): |
| 114 | + """ |
| 115 | + Model for DataFrameType type |
| 116 | + All members must be the same as main type for this model |
120 | 117 |
|
121 | | - Test: python -m sdc.runtests sdc.tests.test_dataframe.TestDataFrame.test_create_numeric_column |
122 | | - """ |
| 118 | + Test: python -m sdc.runtests sdc.tests.test_dataframe.TestDataFrame.test_create_numeric_column |
| 119 | + """ |
| 120 | + |
| 121 | + def __init__(self, dmm, fe_type): |
| 122 | + members = [ |
| 123 | + ('data', fe_type.data) |
| 124 | + ] |
| 125 | + models.StructModel.__init__(self, dmm, fe_type, members) |
123 | 126 |
|
124 | | - def __init__(self, dmm, fe_type): |
125 | | - members = [ |
126 | | - ('data', fe_type.data) |
127 | | - ] |
128 | | - models.StructModel.__init__(self, dmm, fe_type, members) |
129 | 127 |
|
130 | | - make_attribute_wrapper(DataFrameType, 'data', '_data') |
| 128 | +make_attribute_wrapper(DataFrameType, 'data', '_data') |
131 | 129 |
|
132 | 130 |
|
133 | 131 | @intrinsic |
@@ -164,65 +162,65 @@ def _hpat_pandas_dataframe_init_codegen(context, builder, signature, args): |
164 | 162 | return sig, _hpat_pandas_dataframe_init_codegen |
165 | 163 |
|
166 | 164 |
|
167 | | -if not config_pipeline_hpat_default: |
168 | | - @overload(pandas.DataFrame) |
169 | | - def hpat_pandas_dataframe(data=None, index=None, columns=None, dtype=None, copy=False): |
170 | | - """ |
171 | | - Special Numba procedure to overload Python type pandas.DataFrame::ctor() with Numba registered model |
172 | | - """ |
| 165 | +@overload(pandas.DataFrame) |
| 166 | +def hpat_pandas_dataframe(data=None, index=None, columns=None, dtype=None, copy=False): |
| 167 | + """ |
| 168 | + Special Numba procedure to overload Python type pandas.DataFrame::ctor() with Numba registered model |
| 169 | + """ |
173 | 170 |
|
174 | | - if isinstance(data, types.DictType): |
175 | | - def hpat_pandas_dataframe_impl(data=None, index=None, columns=None, dtype=None, copy=False): |
176 | | - series_dict = {} |
177 | | - series_list = [] |
| 171 | + if isinstance(data, types.DictType): |
| 172 | + def hpat_pandas_dataframe_impl(data=None, index=None, columns=None, dtype=None, copy=False): |
| 173 | + series_dict = {} |
| 174 | + series_list = [] |
178 | 175 |
|
179 | | - for key, value in data.items(): |
180 | | - """ |
181 | | - Convert input dictionary with: |
182 | | - key - unicode string |
183 | | - value - array |
184 | | - into dictinary of pandas.Series with same names and values |
185 | | - """ |
| 176 | + for key, value in data.items(): |
| 177 | + """ |
| 178 | + Convert input dictionary with: |
| 179 | + key - unicode string |
| 180 | + value - array |
| 181 | + into dictinary of pandas.Series with same names and values |
| 182 | + """ |
186 | 183 |
|
187 | | - series_item = pandas.Series(data=value, name=key) |
188 | | - series_dict[key] = series_item |
189 | | - series_list.append(series_item) |
| 184 | + series_item = pandas.Series(data=value, name=key) |
| 185 | + series_dict[key] = series_item |
| 186 | + series_list.append(series_item) |
190 | 187 |
|
191 | | - # return _hpat_pandas_dataframe_init(series_dict) |
192 | | - return _hpat_pandas_dataframe_init(series_list) |
| 188 | + # return _hpat_pandas_dataframe_init(series_dict) |
| 189 | + return _hpat_pandas_dataframe_init(series_list) |
193 | 190 |
|
194 | | - return hpat_pandas_dataframe_impl |
| 191 | + return hpat_pandas_dataframe_impl |
195 | 192 |
|
196 | | - @box(DataFrameType) |
197 | | - def hpat_pandas_dataframe_box(typ, val, c): |
198 | | - """ |
199 | | - This method is to copy data from JITted region data structure |
200 | | - to new Python object data structure. |
201 | | - Python object data structure has creating in this procedure. |
202 | | - """ |
203 | 193 |
|
204 | | - dataframe = cgutils.create_struct_proxy(typ)(c.context, c.builder, value=val) |
| 194 | +@box(DataFrameType) |
| 195 | +def hpat_pandas_dataframe_box(typ, val, c): |
| 196 | + """ |
| 197 | + This method is to copy data from JITted region data structure |
| 198 | + to new Python object data structure. |
| 199 | + Python object data structure has creating in this procedure. |
| 200 | + """ |
205 | 201 |
|
206 | | - ir_ptr_data = c.box(typ.data, dataframe.data) |
| 202 | + dataframe = cgutils.create_struct_proxy(typ)(c.context, c.builder, value=val) |
207 | 203 |
|
208 | | - dataframe_ctor_args = c.pyapi.tuple_pack([ir_ptr_data, ]) |
209 | | - # dataframe_ctor_kwargs = c.pyapi.dict_pack([("data", ir_ptr_data), ]) |
210 | | - """ |
211 | | - It is better to use kwargs but it fails into SIGSEGV |
212 | | - """ |
| 204 | + ir_ptr_data = c.box(typ.data, dataframe.data) |
213 | 205 |
|
214 | | - dataframe_ctor_fn = c.pyapi.unserialize(c.pyapi.serialize_object(pandas.DataFrame)) |
215 | | - """ |
216 | | - Create a pandas.DataFrame ctor() function pointer |
217 | | - """ |
| 206 | + dataframe_ctor_args = c.pyapi.tuple_pack([ir_ptr_data, ]) |
| 207 | + # dataframe_ctor_kwargs = c.pyapi.dict_pack([("data", ir_ptr_data), ]) |
| 208 | + """ |
| 209 | + It is better to use kwargs but it fails into SIGSEGV |
| 210 | + """ |
218 | 211 |
|
219 | | - df_obj = c.pyapi.call(dataframe_ctor_fn, dataframe_ctor_args) # kws=dataframe_ctor_kwargs) |
220 | | - """ |
221 | | - Call pandas.DataFrame function pointer with parameters |
222 | | - """ |
| 212 | + dataframe_ctor_fn = c.pyapi.unserialize(c.pyapi.serialize_object(pandas.DataFrame)) |
| 213 | + """ |
| 214 | + Create a pandas.DataFrame ctor() function pointer |
| 215 | + """ |
| 216 | + |
| 217 | + df_obj = c.pyapi.call(dataframe_ctor_fn, dataframe_ctor_args) # kws=dataframe_ctor_kwargs) |
| 218 | + """ |
| 219 | + Call pandas.DataFrame function pointer with parameters |
| 220 | + """ |
223 | 221 |
|
224 | | - c.pyapi.decref(ir_ptr_data) |
225 | | - c.pyapi.decref(dataframe_ctor_args) |
226 | | - c.pyapi.decref(dataframe_ctor_fn) |
| 222 | + c.pyapi.decref(ir_ptr_data) |
| 223 | + c.pyapi.decref(dataframe_ctor_args) |
| 224 | + c.pyapi.decref(dataframe_ctor_fn) |
227 | 225 |
|
228 | | - return df_obj |
| 226 | + return df_obj |
0 commit comments