Skip to content
This repository was archived by the owner on Feb 2, 2024. It is now read-only.

Commit 17ab7fe

Browse files
committed
Minor updates
1 parent 01d2ac5 commit 17ab7fe

File tree

3 files changed

+5
-57
lines changed

3 files changed

+5
-57
lines changed

sdc/hiframes/pd_series_type.py

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
from numba.core import cgutils
3333
from numba.np.numpy_support import from_dtype
3434
from numba.extending import (models, register_model, make_attribute_wrapper, lower_builtin)
35-
from numba.core.imputils import (impl_ret_new_ref, iternext_impl, RefType)
35+
from numba.core.imputils import (impl_ret_untracked, call_getiter, iternext_impl, RefType)
3636
from numba.np.arrayobj import make_array, _getitem_array_single_int
3737

3838
from sdc.str_ext import string_type, list_string_array_type
@@ -168,8 +168,6 @@ def __init__(self, dmm, fe_type):
168168
models.StructModel.__init__(self, dmm, fe_type, members)
169169

170170

171-
from numba.core.imputils import impl_ret_untracked, call_getiter
172-
## FIXME: why is it here and not in series functions?
173171
@lower_builtin('getiter', SeriesType)
174172
def getiter_series(context, builder, sig, args):
175173
"""
@@ -183,32 +181,6 @@ def getiter_series(context, builder, sig, args):
183181
:return: reference to iterator
184182
"""
185183

186-
# arraytype = sig.args[0].data
187-
#
188-
# # Create instruction to get array to iterate
189-
# zero_member_pointer = context.get_constant(types.intp, 0)
190-
# zero_member = context.get_constant(types.int32, 0)
191-
# alloca = args[0].operands[0]
192-
# gep_result = builder.gep(alloca, [zero_member_pointer, zero_member])
193-
# array = builder.load(gep_result)
194-
#
195-
# # TODO: call numba getiter with gep_result for array
196-
# iterobj = context.make_helper(builder, sig.return_type)
197-
# zero_index = context.get_constant(types.intp, 0)
198-
# indexptr = cgutils.alloca_once_value(builder, zero_index)
199-
#
200-
# iterobj.index = indexptr
201-
# iterobj.array = array
202-
#
203-
# if context.enable_nrt:
204-
# context.nrt.incref(builder, arraytype, array)
205-
#
206-
# result = iterobj._getvalue()
207-
# # Note: a decref on the iterator will dereference all internal MemInfo*
208-
# out = impl_ret_new_ref(context, builder, sig.return_type, result)
209-
# return out
210-
211-
### FIXME: this can be the fix (at least for numeric series), but why the above stopped to work?
212184
(value,) = args
213185
series_obj = cgutils.create_struct_proxy(sig.args[0])(context, builder, value)
214186
res = call_getiter(context, builder, sig.args[0].data, series_obj.data)

sdc/str_ext.py

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import llvmlite.llvmpy.core as lc
3131
from llvmlite import ir as lir
3232
import llvmlite.binding as ll
33+
import numpy as np
3334

3435
import numba
3536
from numba.core import cgutils, types
@@ -406,16 +407,6 @@ def generic(self, args, kws):
406407
return signature(types.float64, arg)
407408

408409

409-
# FIXME: this is typing for broken impl
410-
# @infer_global(str)
411-
# class StrConstInfer(AbstractTemplate):
412-
# def generic(self, args, kws):
413-
# assert not kws
414-
# assert len(args) == 1
415-
# assert args[0] in [types.int32, types.int64, types.float32, types.float64, string_type]
416-
# return signature(string_type, *args)
417-
418-
419410
class RegexType(types.Opaque):
420411
def __init__(self):
421412
super(RegexType, self).__init__(name='RegexType')
@@ -673,22 +664,6 @@ def const_to_string_type(context, builder, fromty, toty, val):
673664
return ret
674665

675666

676-
### FIXME: this impl introduces problem!
677-
'''
678-
@lower_builtin(str, types.Any)
679-
def string_from_impl(context, builder, sig, args):
680-
in_typ = sig.args[0]
681-
if in_typ == string_type:
682-
return args[0]
683-
ll_in_typ = context.get_value_type(sig.args[0])
684-
fnty = lir.FunctionType(lir.IntType(8).as_pointer(), [ll_in_typ])
685-
fn = cgutils.get_or_insert_function(builder.module,
686-
fnty, name="str_from_" + str(in_typ))
687-
std_str = builder.call(fn, args)
688-
return gen_std_str_to_unicode(context, builder, std_str)
689-
'''
690-
691-
import numpy as np
692667
@overload(str)
693668
def str_from_float_ovld(val):
694669
if not isinstance(val, types.Float):
@@ -825,7 +800,8 @@ def cast_str_to_int64(context, builder, fromty, toty, val):
825800
fnty = lir.FunctionType(lir.IntType(64), [lir.IntType(8).as_pointer()])
826801
fn = cgutils.get_or_insert_function(builder.module, fnty, name="std_str_to_int64")
827802
return builder.call(fn, (val,))
828-
803+
804+
829805
# # XXX handle unicode until Numba supports int(str)
830806
# @lower_cast(string_type, types.int64)
831807
# def cast_unicode_str_to_int64(context, builder, fromty, toty, val):

sdc/tests/test_strings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ def test_impl(a):
160160
with self.subTest(val=val):
161161
result_ref = test_impl(val)
162162
result = sdc_func(val)
163-
### FIXME: return back comment
163+
# XXX: use startswith since hpat output can have extra characters
164164
self.assertTrue(result.startswith(result_ref),
165165
f"result={result} not started with {result_ref}")
166166

0 commit comments

Comments
 (0)