def apply(self): init_df_stmt = import_function(init_dataframe, self._block, self._func_ir) for stmt in self._calls_to_rewrite: args = get_call_parameters(call=stmt.value, arg_names=self._df_arg_list) old_data = args['data'] args['data'], args['columns'] = self._extract_dict_args(args, self._func_ir) self._replace_call(stmt, init_df_stmt.target, args, self._block, self._func_ir) remove_unused_recursively(old_data, self._block, self._func_ir) return self._block
def apply(self): """ Replace call to zip in matched expressions with call to sdc_zip. """ new_block = self._block.copy() new_block.clear() zip_spec_stmt = import_function(sdc_tuple_zip, new_block, self._func_ir) for inst in self._block.body: if isinstance(inst, ir.Assign) and inst.value in self._calls_to_rewrite: expr = inst.value expr.func = zip_spec_stmt.target # injects the new function new_block.append(inst) return new_block
def apply(self): for stmt in self._calls_to_rewrite: args = get_call_parameters(call=stmt.value, arg_names=self._df_arg_list) old_data = args['data'] args['data'], args['columns'] = self._extract_dict_args( args, self._func_ir) args_len = len(args['data']) func_name = f'init_dataframe_{args_len}' # injected_module = modules[pd_dataframe_ext_module.__name__] init_df = getattr(pd_dataframe_ext_module, func_name, None) if init_df is None: init_df_text = gen_init_dataframe_text(func_name, args_len) init_df = gen_init_dataframe_func( func_name, init_df_text, { 'numba': numba, 'cgutils': cgutils, 'signature': signature, 'types': types, 'get_structure_maps': get_structure_maps, 'intrinsic': intrinsic, 'DataFrameType': DataFrameType, 'ColumnLoc': ColumnLoc, 'string_type': string_type, 'intrinsic': intrinsic, 'fix_df_array': fix_df_array, 'fix_df_index': fix_df_index, 'init_empty_index': init_empty_index, 'EmptyIndexType': EmptyIndexType }) setattr(pd_dataframe_ext_module, func_name, init_df) init_df.__module__ = pd_dataframe_ext_module.__name__ init_df._defn.__module__ = pd_dataframe_ext_module.__name__ init_df_stmt = import_function(init_df, self._block, self._func_ir) self._replace_call(stmt, init_df_stmt.target, args, self._block, self._func_ir) remove_unused_recursively(old_data, self._block, self._func_ir) self._pipeline.typingctx.refresh() return self._block