Skip to content
This repository was archived by the owner on Feb 2, 2024. It is now read-only.
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
use sdc_join_series_indexes
  • Loading branch information
Rubtsowa committed May 13, 2020
commit aeef026002d4da4db5b8e15a11df0384bb36f5d6
22 changes: 14 additions & 8 deletions sdc/datatypes/hpat_pandas_series_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4930,17 +4930,23 @@ def sdc_pandas_series_combine_impl(self, other, func, fill_value=None):
if fill_value is None:
fill_value = numpy.nan

len_val = max(len(self), len(other))
indexes, self_indexes, other_indexes = sdc_join_series_indexes(self.index, other.index)
len_val = len(indexes)
result = numpy.empty(len_val, self._data.dtype)

@kozlov-alexey kozlov-alexey May 21, 2020 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually wrong, result dtype should be common dtype for result dtype of func(a, b) where a,b are series values and dtype of _fill_value. Provided tests do not cover this, but e.g. this (where fill_value is float and series are integers) won't pass:

    def test_series_combine_integer_new(self):
        def test_impl(S1, S2):
            return S1.combine(S2, lambda a, b: 2 * a + b, 16.2)
        hpat_func = self.jit(test_impl)

        S1 = pd.Series([1, 2, 3, 4, 5])
        S2 = pd.Series([6, 21, 3, 5])
        result = hpat_func(S1, S2)
        result_ref = test_impl(S1, S2)
        print(f"DEBUG: result:\n{result},\nresult_ref:\n{result_ref}")
        pd.testing.assert_series_equal(result, result_ref)

for ind in range(len_val):
val_self = self._data[ind]
val_other = other._data[ind]
if len(self) < ind + 1:

for i in range(len_val):
if self_indexes[i] == -1:
val_self = fill_value
if len(other) < ind + 1:
else:
ind_self = self_indexes[i]
val_self = self._data[ind_self]
if other_indexes[i] == -1:
val_other = fill_value
result[ind] = func(val_self, val_other)
else:
ind_other = other_indexes[i]
val_other = other._data[ind_other]
result[i] = func(val_self, val_other)

return pandas.Series(result)
return pandas.Series(result, index=indexes)

return sdc_pandas_series_combine_impl