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

Commit

Permalink
Merge a60740a into c6397f4
Browse files Browse the repository at this point in the history
  • Loading branch information
kozlov-alexey committed Jul 17, 2019
2 parents c6397f4 + a60740a commit 786e0d7
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 26 deletions.
2 changes: 1 addition & 1 deletion hpat/hiframes/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ def generic(self, args, kws):
class FillNaStrType(AbstractTemplate):
def generic(self, args, kws):
assert not kws
assert len(args) == 2
assert len(args) == 3
# args: in_arr, value
return signature(SeriesType(string_type), *args)

Expand Down
13 changes: 5 additions & 8 deletions hpat/hiframes/hiframes_typed.py
Original file line number Diff line number Diff line change
Expand Up @@ -1114,6 +1114,7 @@ def _run_call_series_fillna(self, assign, lhs, rhs, series_var):
val = rhs.args[0]
nodes = []
data = self._get_series_data(series_var, nodes)
name = self._get_series_name(series_var, nodes)
kws = dict(rhs.kws)
inplace = False
if 'inplace' in kws:
Expand All @@ -1133,18 +1134,14 @@ def _run_call_series_fillna(self, assign, lhs, rhs, series_var):
# array and assign it back to the same Series variable
# result back to the same variable
# TODO: handle string array reflection
def str_fillna_impl(A, fill):
def str_fillna_impl(A, fill, name):
# not using A.fillna since definition list is not working
# for A to find callname
return hpat.hiframes.api.fillna_str_alloc(A, fill)
return hpat.hiframes.api.fillna_str_alloc(A, fill, name)
#A.fillna(fill)

fill_var = rhs.args[0]
assign.target = series_var # replace output
return self._replace_func(
str_fillna_impl,
[data, fill_var],
pre_nodes=nodes)
return self._replace_func(str_fillna_impl, [data, val, name], pre_nodes=nodes)
else:
return self._replace_func(
lambda a,b,c: hpat.hiframes.api.fillna(a,b,c),
Expand All @@ -1155,7 +1152,7 @@ def str_fillna_impl(A, fill):
func = series_replace_funcs['fillna_str_alloc']
else:
func = series_replace_funcs['fillna_alloc']
return self._replace_func(func, [data, val], pre_nodes=nodes)
return self._replace_func(func, [data, val, name], pre_nodes=nodes)

def _run_call_series_dropna(self, assign, lhs, rhs, series_var):
dtype = self.typemap[series_var.name].dtype
Expand Down
8 changes: 4 additions & 4 deletions hpat/hiframes/series_kernels.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def _column_fillna_impl(A, B, fill): # pragma: no cover
s = fill
A[i] = s

def _series_fillna_str_alloc_impl(B, fill): # pragma: no cover
def _series_fillna_str_alloc_impl(B, fill, name): # pragma: no cover
n = len(B)
num_chars = 0
# get total chars in new array
Expand All @@ -55,7 +55,7 @@ def _series_fillna_str_alloc_impl(B, fill): # pragma: no cover
num_chars += len(s)
A = hpat.str_arr_ext.pre_alloc_string_array(n, num_chars)
hpat.hiframes.api.fillna(A, B, fill)
return hpat.hiframes.api.init_series(A)
return hpat.hiframes.api.init_series(A, None, name)

def _series_dropna_float_impl(S, name): # pragma: no cover
old_len = len(S)
Expand Down Expand Up @@ -304,11 +304,11 @@ def _column_describe_impl(S): # pragma: no cover
"max " + str(a_max) + "\n"
return res

def _column_fillna_alloc_impl(S, val): # pragma: no cover
def _column_fillna_alloc_impl(S, val, name): # pragma: no cover
# TODO: handle string, etc.
B = np.empty(len(S), S.dtype)
hpat.hiframes.api.fillna(B, S, val)
return hpat.hiframes.api.init_series(B)
return hpat.hiframes.api.init_series(B, None, name)


def _str_contains_regex_impl(str_arr, pat): # pragma: no cover
Expand Down
23 changes: 10 additions & 13 deletions hpat/tests/test_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -611,13 +611,6 @@ def test_impl(A):
hpat_func = hpat.jit(test_impl)
self.assertTrue(isinstance(hpat_func(df.A), np.ndarray))

@unittest.skip('numba.errors.LoweringError - fix needed\n'
'Failed in hpat mode pipeline '
'(step: nopython mode backend)\n'
'expecting {{i8*, i8*, i64, i64, double*, [1 x i64], '
'[1 x i64]}, i8*, {i8*, i64, i32, i32, i64, i8*, i8*}} \n'
'but got {{i8*, i8*, i64, i64, double*, [1 x i64], '
'[1 x i64]}, i8*, i8*}\n')
def test_series_fillna1(self):
def test_impl(A):
return A.fillna(5.0)
Expand All @@ -627,12 +620,16 @@ def test_impl(A):
pd.testing.assert_series_equal(hpat_func(df.A), test_impl(df.A),
check_names=False)

@unittest.skip('numba.errors.LoweringError - fix needed\n'
'Failed in hpat mode pipeline '
'(step: nopython mode backend)\n'
'expecting {{i64, i64, i32*, i8*, i8*, i8*}, i8*, '
'{i8*, i64, i32, i32, i64, i8*, i8*}} \n'
'but got {{i64, i64, i32*, i8*, i8*, i8*}, i8*, i8*}\n')
def test_series_fillna_inplace1(self):
def test_impl(A):
A.fillna(5.0, inplace=True)
return A

df = pd.DataFrame({'A': [1.0, 2.0, np.nan, 1.0]})
hpat_func = hpat.jit(test_impl)
pd.testing.assert_series_equal(hpat_func(df.A), test_impl(df.A),
check_names=False)

def test_series_fillna_str1(self):
def test_impl(A):
return A.fillna("dd")
Expand Down

0 comments on commit 786e0d7

Please sign in to comment.