Beispiel #1
0
def _str_replace_regex_impl(str_arr, pat, val):
    numba.parfor.init_prange()
    e = hpat.str_ext.compile_regex(unicode_to_std_str(pat))
    val = unicode_to_std_str(val)
    n = len(str_arr)
    n_total_chars = 0
    str_list = hpat.str_ext.alloc_str_list(n)
    for i in numba.parfor.internal_prange(n):
        # TODO: support unicode
        in_str = unicode_to_std_str(str_arr[i])
        out_str = std_str_to_unicode(
            hpat.str_ext.str_replace_regex(in_str, e, val))
        str_list[i] = out_str
        n_total_chars += len(out_str)
    numba.parfor.init_prange()
    out_arr = pre_alloc_string_array(n, n_total_chars)
    for i in numba.parfor.internal_prange(n):
        _str = str_list[i]
        out_arr[i] = _str
    return hpat.hiframes.api.init_series(out_arr)
Beispiel #2
0
 def test_impl(_str, pat, val):
     s = unicode_to_std_str(_str)
     e = unicode_to_std_str(pat)
     val = unicode_to_std_str(val)
     out = hpat.str_ext.str_replace_noregex(s, e, val)
     return std_str_to_unicode(out)