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

Commit

Permalink
Merge 085ae9a into 8e3a220
Browse files Browse the repository at this point in the history
  • Loading branch information
1e-to committed Oct 25, 2019
2 parents 8e3a220 + 085ae9a commit 5202d2b
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 9 deletions.
39 changes: 39 additions & 0 deletions hpat/datatypes/hpat_pandas_series_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,45 @@ def hpat_pandas_series_isna_impl(self):
return hpat_pandas_series_isna_impl


@overload_method(SeriesType, 'notna')
def hpat_pandas_series_notna(self):
"""
Pandas Series method :meth:`pandas.Series.notna` implementation.
.. only:: developer
Test: python -m -k hpat.runtests hpat.tests.test_series.TestSeries.test_series_notna*
Parameters
-----------
self : :obj:`pandas.Series` object
input series
Returns
-------
:obj:`pandas.Series`
returns :obj:`pandas.Series` object
"""

_func_name = 'Method notna().'

if not isinstance(self, SeriesType):
raise TypingError('{} The object must be a pandas.series. Given: {}'.format(_func_name, self))

if isinstance(self.data.dtype, types.Number):
def hpat_pandas_series_notna_impl(self):
return pandas.Series(numpy.invert(numpy.isnan(self._data)))

return hpat_pandas_series_notna_impl

if isinstance(self.data.dtype, types.UnicodeType):
def hpat_pandas_series_notna_impl(self):
result = self.isna()
return pandas.Series(numpy.invert(result._data))

return hpat_pandas_series_notna_impl


@overload_method(SeriesType, 'ne')
def hpat_pandas_series_ne(self, other, level=None, fill_value=None, axis=0):
"""
Expand Down
8 changes: 4 additions & 4 deletions hpat/hiframes/hiframes_typed.py
Original file line number Diff line number Diff line change
Expand Up @@ -1006,10 +1006,10 @@ def run_call_series_quantile_default(A):
func = series_replace_funcs['append_tuple']
return self._replace_func(func, [data, other], pre_nodes=nodes)

if func_name == 'notna':
# TODO: make sure this is fused and optimized properly
return self._replace_func(
lambda S: S.isna() == False, [series_var])
# if func_name == 'notna':
# # TODO: make sure this is fused and optimized properly
# return self._replace_func(
# lambda S: S.isna() == False, [series_var])

if func_name == 'value_counts':
nodes = []
Expand Down
10 changes: 5 additions & 5 deletions hpat/hiframes/pd_series_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -666,11 +666,11 @@ def resolve_isnull(self, ary, args, kws):
assert not args
return signature(SeriesType(types.boolean))

@bound_function("series.notna")
def resolve_notna(self, ary, args, kws):
assert not kws
assert not args
return signature(SeriesType(types.boolean))
# @bound_function("series.notna")
# def resolve_notna(self, ary, args, kws):
# assert not kws
# assert not args
# return signature(SeriesType(types.boolean))

@bound_function("series.nlargest")
def resolve_nlargest(self, ary, args, kws):
Expand Down
54 changes: 54 additions & 0 deletions hpat/tests/test_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -1756,6 +1756,60 @@ def test_impl(S):
S = pd.Series([np.nan, 2., 3.])
pd.testing.assert_series_equal(hpat_func(S), test_impl(S))

def test_series_notna_noidx_float(self):
def test_impl(S):
return S.notna()

hpat_func = hpat.jit(test_impl)
for input_data in test_global_input_data_float64:
S = pd.Series(input_data)
result_ref = test_impl(S)
result_jit = hpat_func(S)
pd.testing.assert_series_equal(result_jit, result_ref)

@unittest.skip("Need fix test_global_input_data_integer64")
def test_series_notna_noidx_int(self):
def test_impl(S):
return S.notna()

hpat_func = hpat.jit(test_impl)
for input_data in test_global_input_data_integer64:
S = pd.Series(input_data)
result_ref = test_impl(S)
result_jit = hpat_func(S)
pd.testing.assert_series_equal(result_jit, result_ref)

@unittest.skip("Need fix test_global_input_data_integer64")
def test_series_notna_noidx_num(self):
def test_impl(S):
return S.notna()

hpat_func = hpat.jit(test_impl)
for input_data in test_global_input_data_numeric:
S = pd.Series(input_data)
result_ref = test_impl(S)
result_jit = hpat_func(S)
pd.testing.assert_series_equal(result_jit, result_ref)

def test_series_notna_noidx_str(self):
def test_impl(S):
return S.notna()

hpat_func = hpat.jit(test_impl)
input_data = test_global_input_data_unicode_kind4
S = pd.Series(input_data)
result_ref = test_impl(S)
result_jit = hpat_func(S)
pd.testing.assert_series_equal(result_jit, result_ref)

def test_series_str_notna(self):
def test_impl(S):
return S.notna()
hpat_func = hpat.jit(test_impl)

S = pd.Series(['aa', None, 'c', 'cccd'])
pd.testing.assert_series_equal(hpat_func(S), test_impl(S))

def test_series_str_isna1(self):
def test_impl(S):
return S.isna()
Expand Down

0 comments on commit 5202d2b

Please sign in to comment.