def sdc_pandas_dataframe_rolling_cov(self, other=None, pairwise=None, ddof=1):

    ty_checker = TypeChecker('Method rolling.cov().')
    ty_checker.check(self, DataFrameRollingType)

    accepted_other = (Omitted, NoneType, DataFrameType, SeriesType)
    if not isinstance(other, accepted_other) and other is not None:
        ty_checker.raise_exc(other, 'DataFrame, Series', 'other')

    accepted_pairwise = (bool, Boolean, Omitted, NoneType)
    if not isinstance(pairwise, accepted_pairwise) and pairwise is not None:
        ty_checker.raise_exc(pairwise, 'bool', 'pairwise')

    if not isinstance(ddof, (int, Integer, Omitted)):
        ty_checker.raise_exc(ddof, 'int', 'ddof')

    none_other = isinstance(other, (Omitted, NoneType)) or other is None
    kws = {'other': 'None', 'pairwise': 'None', 'ddof': '1'}

    if none_other:
        # method _df_cov in comparison to method cov doesn't align input data
        # by replacing infinite and matched finite values with nans
        return gen_df_rolling_cov_other_none_impl('_df_cov', self, kws=kws)

    if isinstance(other, DataFrameType):
        return gen_df_rolling_method_other_df_impl('cov', self, other, kws=kws)

    return gen_df_rolling_method_impl('cov', self, kws=kws)
def sdc_pandas_dataframe_rolling_corr(self, other=None, pairwise=None):

    ty_checker = TypeChecker('Method rolling.corr().')
    ty_checker.check(self, DataFrameRollingType)

    accepted_other = (Omitted, NoneType, DataFrameType, SeriesType)
    if not isinstance(other, accepted_other) and other is not None:
        ty_checker.raise_exc(other, 'DataFrame, Series', 'other')

    accepted_pairwise = (bool, Boolean, Omitted, NoneType)
    if not isinstance(pairwise, accepted_pairwise) and pairwise is not None:
        ty_checker.raise_exc(pairwise, 'bool', 'pairwise')

    none_other = isinstance(other, (Omitted, NoneType)) or other is None
    kws = {'other': 'None', 'pairwise': 'None'}

    if none_other:
        return gen_df_rolling_method_other_none_impl('corr', self, kws=kws)

    if isinstance(other, DataFrameType):
        return gen_df_rolling_method_other_df_impl('corr',
                                                   self,
                                                   other,
                                                   kws=kws)

    return gen_df_rolling_method_impl('corr', self, kws=kws)
def hpat_pandas_series_rolling_count(self):

    ty_checker = TypeChecker('Method rolling.count().')
    ty_checker.check(self, SeriesRollingType)

    def hpat_pandas_rolling_series_count_impl(self):
        win = self._window

        input_series = self._data
        input_arr = input_series._data
        length = len(input_arr)
        output_arr = numpy.empty(length, dtype=float64)

        boundary = min(win, length)
        for i in prange(boundary):
            arr_range = input_arr[:i + 1]
            output_arr[i] = arr_nonnan_count(arr_range)

        for i in prange(boundary, length):
            arr_range = input_arr[i + 1 - win:i + 1]
            output_arr[i] = arr_nonnan_count(arr_range)

        return pandas.Series(output_arr,
                             input_series._index,
                             name=input_series._name)

    return hpat_pandas_rolling_series_count_impl
Exemple #4
0
def argsort_overload(a, axis=-1, kind=None, order=None):
    _func_name = 'argsort'
    ty_checker = TypeChecker(_func_name)

    ty_checker.check(a, types.Array)

    if not is_default(axis, -1):
        raise TypingError(f'{_func_name} Unsupported parameter axis')

    if not is_default(order, None):
        raise TypingError(f'{_func_name} Unsupported parameter order')

    def argsort_impl(a, axis=-1, kind=None, order=None):
        _kind = 'quicksort'
        if kind is not None:
            _kind = kind

        if _kind == 'quicksort':
            return parallel_argsort(a)
        elif _kind == 'mergesort':
            return parallel_stable_argsort(a)
        else:
            raise ValueError("Unsupported value of 'kind' parameter")

    return argsort_impl
def hpat_pandas_stringmethods_strip(self, to_strip=None):
    ty_checker = TypeChecker('Method strip().')
    ty_checker.check(self, StringMethodsType)

    if not isinstance(to_strip, (NoneType, StringLiteral, UnicodeType, Omitted)) and to_strip is not None:
        ty_checker.raise_exc(to_strip, 'str', 'to_strip')

    return sdc_pandas_series_str_strip_impl
def hpat_pandas_series_rolling_corr(self, other=None, pairwise=None):

    ty_checker = TypeChecker('Method rolling.corr().')
    ty_checker.check(self, SeriesRollingType)

    # TODO: check `other` is Series after a circular import of SeriesType fixed
    # accepted_other = (bool, Omitted, NoneType, SeriesType)
    # if not isinstance(other, accepted_other) and other is not None:
    #     ty_checker.raise_exc(other, 'Series', 'other')

    accepted_pairwise = (bool, Boolean, Omitted, NoneType)
    if not isinstance(pairwise, accepted_pairwise) and pairwise is not None:
        ty_checker.raise_exc(pairwise, 'bool', 'pairwise')

    nan_other = isinstance(other, (Omitted, NoneType)) or other is None

    def hpat_pandas_rolling_series_corr_impl(self, other=None, pairwise=None):
        win = self._window
        minp = self._min_periods

        main_series = self._data
        main_arr = main_series._data
        main_arr_length = len(main_arr)

        if nan_other == True:  # noqa
            other_arr = main_arr
        else:
            other_arr = other._data

        other_arr_length = len(other_arr)
        length = max(main_arr_length, other_arr_length)
        output_arr = numpy.empty(length, dtype=float64)

        def calc_corr(main, other, minp):
            # align arrays `main` and `other` by size and finiteness
            min_length = min(len(main), len(other))
            main_valid_indices = numpy.isfinite(main[:min_length])
            other_valid_indices = numpy.isfinite(other[:min_length])
            valid = main_valid_indices & other_valid_indices

            if len(main[valid]) < minp:
                return numpy.nan
            else:
                return arr_corr(main[valid], other[valid])

        for i in prange(min(win, length)):
            main_arr_range = main_arr[:i + 1]
            other_arr_range = other_arr[:i + 1]
            output_arr[i] = calc_corr(main_arr_range, other_arr_range, minp)

        for i in prange(win, length):
            main_arr_range = main_arr[i + 1 - win:i + 1]
            other_arr_range = other_arr[i + 1 - win:i + 1]
            output_arr[i] = calc_corr(main_arr_range, other_arr_range, minp)

        return pandas.Series(output_arr)

    return hpat_pandas_rolling_series_corr_impl
def hpat_pandas_series_rolling_var(self, ddof=1):

    ty_checker = TypeChecker('Method rolling.var().')
    ty_checker.check(self, SeriesRollingType)

    if not isinstance(ddof, (int, Integer, Omitted)):
        ty_checker.raise_exc(ddof, 'int', 'ddof')

    return sdc_pandas_series_rolling_var_impl
def sdc_pandas_dataframe_rolling_var(self, ddof=1):

    ty_checker = TypeChecker('Method rolling.var().')
    ty_checker.check(self, DataFrameRollingType)

    if not isinstance(ddof, (int, Integer, Omitted)):
        ty_checker.raise_exc(ddof, 'int', 'ddof')

    return gen_df_rolling_method_impl('var', self, kws={'ddof': '1'})
def hpat_pandas_stringmethods_center(self, width, fillchar=' '):
    """
    Intel Scalable Dataframe Compiler User Guide
    ********************************************
    Pandas API: pandas.Series.str.center

    Examples
    --------
    .. literalinclude:: ../../../examples/series/str/series_str_center.py
       :language: python
       :lines: 27-
       :caption: Filling left and right side of strings in the Series with an additional character
       :name: ex_series_str_center

    .. command-output:: python ./series/str/series_str_center.py
       :cwd: ../../../examples

    .. seealso::
        :ref:`Series.str.rjust <pandas.Series.str.rjust>`
            Fills the left side of strings with an arbitrary character.
        :ref:`Series.str.ljust <pandas.Series.str.ljust>`
            Fills the right side of strings with an arbitrary character.

    .. todo:: Add support of 32-bit Unicode for `str.center()`

    Intel Scalable Dataframe Compiler Developer Guide
    *************************************************

    Pandas Series method :meth:`pandas.core.strings.StringMethods.center()` implementation.

    .. only:: developer

    Test: python -m sdc.runtests -k sdc.tests.test_series.TestSeries.test_series_center
    """

    ty_checker = TypeChecker('Method center().')
    ty_checker.check(self, StringMethodsType)

    if not isinstance(width, Integer):
        ty_checker.raise_exc(width, 'int', 'width')

    accepted_types = (Omitted, StringLiteral, UnicodeType)
    if not isinstance(fillchar, accepted_types) and fillchar != ' ':
        ty_checker.raise_exc(fillchar, 'str', 'fillchar')

    def hpat_pandas_stringmethods_center_impl(self, width, fillchar=' '):
        mask = get_nan_mask(self._data._data)
        item_count = len(self._data)
        res_list = [''] * item_count
        for idx in numba.prange(item_count):
            res_list[idx] = self._data._data[idx].center(width, fillchar)
        str_arr = create_str_arr_from_list(res_list)
        result = str_arr_set_na_by_mask(str_arr, mask)

        return pandas.Series(result, self._data._index, name=self._data._name)

    return hpat_pandas_stringmethods_center_impl
Exemple #10
0
def sdc_pandas_series_groupby_mean(self, *args):

    method_name = 'GroupBy.mean().'
    ty_checker = TypeChecker(method_name)
    ty_checker.check(self, SeriesGroupByType)

    method_args = ['self', '*args']
    applied_func_name = 'mean'
    return sdc_pandas_series_groupby_apply_func(self, applied_func_name,
                                                method_args)
Exemple #11
0
def sdc_pandas_dataframe_groupby_prod(self):

    method_name = 'GroupBy.prod().'
    ty_checker = TypeChecker(method_name)
    ty_checker.check(self, DataFrameGroupByType)

    method_args = ['self']
    applied_func_name = 'prod'
    return sdc_pandas_dataframe_groupby_apply_func(self, applied_func_name,
                                                   method_args)
Exemple #12
0
def sdc_pandas_series_groupby_sum(self):

    method_name = 'GroupBy.sum().'
    ty_checker = TypeChecker(method_name)
    ty_checker.check(self, SeriesGroupByType)

    method_args = ['self']
    applied_func_name = 'sum'
    return sdc_pandas_series_groupby_apply_func(self, applied_func_name,
                                                method_args)
Exemple #13
0
def _almost_equal_overload(x, y):
    ty_checker = TypeChecker('Function sdc.common_functions._almost_equal_overload().')
    ty_checker.check(x, types.Float)
    ty_checker.check(x, types.Float)

    common_dtype = numpy.find_common_type([], [x.name, y.name])

    def _almost_equal_impl(x, y):
        return abs(x - y) <= numpy.finfo(common_dtype).eps

    return _almost_equal_impl
Exemple #14
0
def sdc_pandas_dataframe_rolling_apply(self, func, raw=None):

    ty_checker = TypeChecker('Method rolling.apply().')
    ty_checker.check(self, DataFrameRollingType)

    raw_accepted = (Omitted, NoneType, Boolean)
    if not isinstance(raw, raw_accepted) and raw is not None:
        ty_checker.raise_exc(raw, 'bool', 'raw')

    return gen_df_rolling_method_impl('apply', self, args=['func'],
                                      kws={'raw': 'None'})
Exemple #15
0
def hpat_pandas_stringmethods_isnumeric(self):
    ty_checker = TypeChecker('Method isnumeric().')
    ty_checker.check(self, StringMethodsType)

    def hpat_pandas_stringmethods_isnumeric_impl(self):
        item_count = len(self._data)
        result = numpy.empty(item_count, numba.types.boolean)
        for idx, item in enumerate(self._data._data):
            result[idx] = item.isnumeric()

        return pandas.Series(result, self._data._index, name=self._data._name)

    return hpat_pandas_stringmethods_isnumeric_impl
Exemple #16
0
def hpat_pandas_series_rolling_quantile(self,
                                        quantile,
                                        interpolation='linear'):

    ty_checker = TypeChecker('Method rolling.quantile().')
    ty_checker.check(self, SeriesRollingType)

    if not isinstance(quantile, Number):
        ty_checker.raise_exc(quantile, 'float', 'quantile')

    str_types = (Omitted, StringLiteral, UnicodeType)
    if not isinstance(interpolation, str_types) and interpolation != 'linear':
        ty_checker.raise_exc(interpolation, 'str', 'interpolation')

    def hpat_pandas_rolling_series_quantile_impl(self,
                                                 quantile,
                                                 interpolation='linear'):
        if quantile < 0 or quantile > 1:
            raise ValueError('quantile value not in [0, 1]')
        if interpolation != 'linear':
            raise ValueError('interpolation value not "linear"')

        win = self._window
        minp = self._min_periods

        input_series = self._data
        input_arr = input_series._data
        length = len(input_arr)
        output_arr = numpy.empty(length, dtype=float64)

        def calc_quantile(arr, quantile, minp):
            finite_arr = arr[numpy.isfinite(arr)]
            if len(finite_arr) < minp:
                return numpy.nan
            else:
                return arr_quantile(finite_arr, quantile)

        boundary = min(win, length)
        for i in prange(boundary):
            arr_range = input_arr[:i + 1]
            output_arr[i] = calc_quantile(arr_range, quantile, minp)

        for i in prange(boundary, length):
            arr_range = input_arr[i + 1 - win:i + 1]
            output_arr[i] = calc_quantile(arr_range, quantile, minp)

        return pandas.Series(output_arr,
                             input_series._index,
                             name=input_series._name)

    return hpat_pandas_rolling_series_quantile_impl
Exemple #17
0
def sdc_pandas_dataframe_rolling_quantile(self, quantile, interpolation='linear'):

    ty_checker = TypeChecker('Method rolling.quantile().')
    ty_checker.check(self, DataFrameRollingType)

    if not isinstance(quantile, Number):
        ty_checker.raise_exc(quantile, 'float', 'quantile')

    str_types = (Omitted, StringLiteral, UnicodeType)
    if not isinstance(interpolation, str_types) and interpolation != 'linear':
        ty_checker.raise_exc(interpolation, 'str', 'interpolation')

    return gen_df_rolling_method_impl('quantile', self, args=['quantile'],
                                      kws={'interpolation': '"linear"'})
def hpat_pandas_stringmethods_len(self):
    """
    Intel Scalable Dataframe Compiler User Guide
    ********************************************
    Pandas API: pandas.Series.str.len

    Limitations
    -----------
    Series elements are expected to be Unicode strings. Elements cannot be `NaNs`.

    Examples
    --------
    .. literalinclude:: ../../../examples/series/str/series_str_len.py
       :language: python
       :lines: 27-
       :caption: Compute the length of each element in the Series
       :name: ex_series_str_len

    .. command-output:: python ./series/str/series_str_len.py
       :cwd: ../../../examples

    .. seealso::
        `str.len`
            Python built-in function returning the length of an object.
        :ref:`Series.size <pandas.Series.size>`
            Returns the length of the Series.

    Intel Scalable Dataframe Compiler Developer Guide
    *************************************************

    Pandas Series method :meth:`pandas.core.strings.StringMethods.len()` implementation.

    .. only:: developer

    Test: python -m sdc.runtests sdc.tests.test_series.TestSeries.test_series_str_len1
    """

    ty_checker = TypeChecker('Method len().')
    ty_checker.check(self, StringMethodsType)

    def hpat_pandas_stringmethods_len_impl(self):
        item_count = len(self._data)
        result = numpy.empty(item_count, numba.types.int64)
        for idx, item in enumerate(self._data._data):
            result[idx] = len(item)

        return pandas.Series(result, self._data._index, name=self._data._name)

    return hpat_pandas_stringmethods_len_impl
def _hpat_pandas_series_rolling_cov_check_types(self, other=None,
                                                pairwise=None, ddof=1):
    """Check types of parameters of series.rolling.cov()"""
    ty_checker = TypeChecker('Method rolling.cov().')
    ty_checker.check(self, SeriesRollingType)

    accepted_other = (bool, Omitted, NoneType, SeriesType)
    if not isinstance(other, accepted_other) and other is not None:
        ty_checker.raise_exc(other, 'Series', 'other')

    accepted_pairwise = (bool, Boolean, Omitted, NoneType)
    if not isinstance(pairwise, accepted_pairwise) and pairwise is not None:
        ty_checker.raise_exc(pairwise, 'bool', 'pairwise')

    if not isinstance(ddof, (int, Integer, Omitted)):
        ty_checker.raise_exc(ddof, 'int', 'ddof')
Exemple #20
0
def hpat_pandas_stringmethods_casefold(self):
    ty_checker = TypeChecker('Method casefold().')
    ty_checker.check(self, StringMethodsType)

    def hpat_pandas_stringmethods_casefold_impl(self):
        mask = get_nan_mask(self._data._data)
        item_count = len(self._data)
        res_list = [''] * item_count
        for idx in numba.prange(item_count):
            res_list[idx] = self._data._data[idx].casefold()
        str_arr = create_str_arr_from_list(res_list)
        result = str_arr_set_na_by_mask(str_arr, mask)

        return pandas.Series(result, self._data._index, name=self._data._name)

    return hpat_pandas_stringmethods_casefold_impl
Exemple #21
0
def _sdc_pandas_series_align_overload(series,
                                      other,
                                      size='max',
                                      finiteness=False):
    ty_checker = TypeChecker(
        'Function sdc.common_functions._sdc_pandas_series_align().')
    ty_checker.check(series, SeriesType)
    ty_checker.check(other, SeriesType)

    str_types = (str, types.StringLiteral, types.UnicodeType, types.Omitted)
    if not isinstance(size, str_types):
        ty_checker.raise_exc(size, 'str', 'size')

    if not isinstance(finiteness, (bool, types.Boolean, types.Omitted)):
        ty_checker.raise_exc(finiteness, 'bool', 'finiteness')

    def _sdc_pandas_series_align_impl(series,
                                      other,
                                      size='max',
                                      finiteness=False):
        if size != 'max' and size != 'min':
            raise ValueError(
                "Function sdc.common_functions._sdc_pandas_series_align(). "
                "The object size\n expected: 'max' or 'min'")

        arr, other_arr = series._data, other._data
        arr_len, other_arr_len = len(arr), len(other_arr)
        min_length = min(arr_len, other_arr_len)
        length = max(arr_len, other_arr_len) if size == 'max' else min_length

        aligned_arr = numpy.repeat([numpy.nan], length)
        aligned_other_arr = numpy.repeat([numpy.nan], length)

        for i in numba.prange(min_length):
            if not finiteness or (numpy.isfinite(arr[i])
                                  and numpy.isfinite(other_arr[i])):
                aligned_arr[i] = arr[i]
                aligned_other_arr[i] = other_arr[i]
            else:
                aligned_arr[i] = aligned_other_arr[i] = numpy.nan

        aligned = pandas.Series(aligned_arr, name=series._name)
        aligned_other = pandas.Series(aligned_other_arr, name=other._name)

        return aligned, aligned_other

    return _sdc_pandas_series_align_impl
Exemple #22
0
def sdc_pandas_series_groupby_var(self, ddof=1, *args):

    method_name = 'GroupBy.var().'
    ty_checker = TypeChecker(method_name)
    ty_checker.check(self, SeriesGroupByType)

    if not isinstance(ddof, (types.Omitted, int, types.Integer)):
        ty_checker.raise_exc(ddof, 'int', 'ddof')

    method_args = ['self', 'ddof', '*args']
    default_values = {'ddof': 1}
    impl_used_params = {'ddof': 'ddof'}

    applied_func_name = 'var'
    return sdc_pandas_series_groupby_apply_func(self, applied_func_name,
                                                method_args, default_values,
                                                impl_used_params)
Exemple #23
0
def hpat_pandas_series_rolling_apply(self, func, raw=None):

    ty_checker = TypeChecker('Method rolling.apply().')
    ty_checker.check(self, SeriesRollingType)

    raw_accepted = (Omitted, NoneType, Boolean)
    if not isinstance(raw, raw_accepted) and raw is not None:
        ty_checker.raise_exc(raw, 'bool', 'raw')

    def hpat_pandas_rolling_series_apply_impl(self, func, raw=None):
        win = self._window
        minp = self._min_periods

        input_series = self._data
        input_arr = input_series._data
        length = len(input_arr)
        output_arr = numpy.empty(length, dtype=float64)

        def culc_apply(arr, func, minp):
            finite_arr = arr.copy()
            finite_arr[numpy.isinf(arr)] = numpy.nan
            if len(finite_arr) < minp:
                return numpy.nan
            else:
                return arr_apply(finite_arr, func)

        boundary = min(win, length)
        for i in prange(boundary):
            arr_range = input_arr[:i + 1]
            output_arr[i] = culc_apply(arr_range, func, minp)

        for i in prange(boundary, length):
            arr_range = input_arr[i + 1 - win:i + 1]
            output_arr[i] = culc_apply(arr_range, func, minp)

        return pandas.Series(output_arr,
                             input_series._index,
                             name=input_series._name)

    return hpat_pandas_rolling_series_apply_impl
def hpat_pandas_stringmethods_upper(self):
    ty_checker = TypeChecker('Method upper().')
    ty_checker.check(self, StringMethodsType)

    def hpat_pandas_stringmethods_upper_impl(self):
        mask = get_nan_mask(self._data._data)
        item_count = len(self._data)
        result = [''] * item_count

        for it in numba.prange(item_count):
            item = self._data._data[it]
            if len(item) > 0:
                result[it] = item.upper()
            else:
                result[it] = item

        str_arr = create_str_arr_from_list(result)
        result = str_arr_set_na_by_mask(str_arr, mask)

        return pandas.Series(result, self._data._index, name=self._data._name)

    return hpat_pandas_stringmethods_upper_impl
def sdc_pandas_dataframe_rolling_sum(self):

    ty_checker = TypeChecker('Method rolling.sum().')
    ty_checker.check(self, DataFrameRollingType)

    return gen_df_rolling_method_impl('sum', self)
def sdc_pandas_series_comp_binop(self,
                                 other,
                                 level=None,
                                 fill_value=None,
                                 axis=0):
    """
    Intel Scalable Dataframe Compiler User Guide
    ********************************************

    Pandas API: pandas.Series.comp_binop

    Limitations
    -----------
    Parameters ``level`` and ``axis`` are currently unsupported by Intel Scalable Dataframe Compiler

    Examples
    --------
    .. literalinclude:: ../../../examples/series/series_comp_binop.py
       :language: python
       :lines: 27-
       :caption:
       :name: ex_series_comp_binop

    .. command-output:: python ./series/series_comp_binop.py
       :cwd: ../../../examples

    Intel Scalable Dataframe Compiler Developer Guide
    *************************************************
    Pandas Series method :meth:`pandas.Series.comp_binop` implementation.

    .. only:: developer
        Test: python -m sdc.runtests -k sdc.tests.test_series.TestSeries.test_series_op8
    """

    _func_name = 'Method comp_binop().'

    ty_checker = TypeChecker(_func_name)
    ty_checker.check(self, SeriesType)

    if not (isinstance(level, types.Omitted) or level is None):
        ty_checker.raise_exc(level, 'None', 'level')

    if not isinstance(fill_value, (types.Omitted, types.Number,
                                   types.NoneType)) and fill_value is not None:
        ty_checker.raise_exc(fill_value, 'number', 'fill_value')

    if not (isinstance(axis, types.Omitted) or axis == 0):
        ty_checker.raise_exc(axis, 'int', 'axis')

    self_is_series, other_is_series = isinstance(self, SeriesType), isinstance(
        other, SeriesType)
    if not (self_is_series or other_is_series):
        return None

    if not isinstance(self, (SeriesType, types.Number, types.UnicodeType)):
        ty_checker.raise_exc(self, 'pandas.series or scalar', 'self')

    if not isinstance(other, (SeriesType, types.Number, types.UnicodeType)):
        ty_checker.raise_exc(other, 'pandas.series or scalar', 'other')

    operands_are_series = self_is_series and other_is_series
    if operands_are_series:
        none_or_numeric_indexes = ((isinstance(self.index, types.NoneType)
                                    or check_index_is_numeric(self))
                                   and (isinstance(other.index, types.NoneType)
                                        or check_index_is_numeric(other)))
        series_indexes_comparable = check_types_comparable(
            self.index, other.index) or none_or_numeric_indexes
        if not series_indexes_comparable:
            raise TypingError(
                '{} Not implemented for series with not-comparable indexes. \
            Given: self.index={}, other.index={}'.format(
                    _func_name, self.index, other.index))

    series_data_comparable = check_types_comparable(self, other)
    if not series_data_comparable:
        raise TypingError('{} Not supported for not-comparable operands. \
        Given: self={}, other={}'.format(_func_name, self, other))

    fill_value_is_none = isinstance(
        fill_value, (types.NoneType, types.Omitted)) or fill_value is None
    if not operands_are_series:

        def _series_comp_binop_scalar_impl(self,
                                           other,
                                           level=None,
                                           fill_value=None,
                                           axis=0):
            if self_is_series == True:  # noqa
                numpy_like.fillna(self._data, inplace=True, value=fill_value)
                return pandas.Series(self._data < other,
                                     index=self._index,
                                     name=self._name)
            else:
                numpy_like.fillna(other._data, inplace=True, value=fill_value)
                return pandas.Series(self < other._data,
                                     index=other._index,
                                     name=other._name)

        return _series_comp_binop_scalar_impl

    else:

        # optimization for series with default indexes, that can be aligned differently
        if (isinstance(self.index, types.NoneType)
                and isinstance(other.index, types.NoneType)):

            def _series_comp_binop_none_indexes_impl(self,
                                                     other,
                                                     level=None,
                                                     fill_value=None,
                                                     axis=0):
                numpy_like.fillna(self._data, inplace=True, value=fill_value)
                numpy_like.fillna(other._data, inplace=True, value=fill_value)
                left_size, right_size = len(self._data), len(other._data)
                if (left_size == right_size):
                    return pandas.Series(self._data < other._data)
                else:
                    raise ValueError(
                        "Can only compare identically-labeled Series objects")

            return _series_comp_binop_none_indexes_impl
        else:
            left_index_is_range = isinstance(self.index,
                                             (RangeIndexType, types.NoneType))
            index_dtypes_match = self.index.dtype == other.index.dtype
            if not index_dtypes_match:
                numba_index_common_dtype = find_common_dtype_from_numpy_dtypes(
                    [self.index.dtype, other.index.dtype], [])
            else:
                numba_index_common_dtype = self.index.dtype

            def _series_comp_binop_common_impl(self,
                                               other,
                                               level=None,
                                               fill_value=None,
                                               axis=0):
                numpy_like.fillna(self._data, inplace=True, value=fill_value)
                numpy_like.fillna(other._data, inplace=True, value=fill_value)
                left_index, right_index = self.index, other.index

                if (left_index is right_index
                        or numpy_like.array_equal(left_index, right_index)):
                    if index_dtypes_match == False:  # noqa
                        new_index = numpy_like.astype(
                            left_index, numba_index_common_dtype)
                    else:
                        new_index = left_index.values if left_index_is_range == True else left_index  # noqa
                    return pandas.Series(self._data < other._data, new_index)
                else:
                    raise ValueError(
                        "Can only compare identically-labeled Series objects")

            return _series_comp_binop_common_impl

    return None
def sdc_pandas_series_comp_binop(self, other, level=None, fill_value=None, axis=0):
    """
    Intel Scalable Dataframe Compiler User Guide
    ********************************************

    Pandas API: pandas.Series.comp_binop

    Limitations
    -----------
    Parameters ``level`` and ``axis`` are currently unsupported by Intel Scalable Dataframe Compiler

    Examples
    --------
    .. literalinclude:: ../../../examples/series/series_comp_binop.py
       :language: python
       :lines: 27-
       :caption:
       :name: ex_series_comp_binop

    .. command-output:: python ./series/series_comp_binop.py
       :cwd: ../../../examples

    Intel Scalable Dataframe Compiler Developer Guide
    *************************************************
    Pandas Series method :meth:`pandas.Series.comp_binop` implementation.

    .. only:: developer
        Test: python -m sdc.runtests -k sdc.tests.test_series.TestSeries.test_series_op8
    """

    _func_name = 'Method comp_binop().'

    ty_checker = TypeChecker(_func_name)
    ty_checker.check(self, SeriesType)

    if not (isinstance(level, types.Omitted) or level is None):
        ty_checker.raise_exc(level, 'None', 'level')

    if not (isinstance(fill_value, (types.Omitted, types.Number, types.UnicodeType, types.NoneType))
            or fill_value is None):
        ty_checker.raise_exc(fill_value, 'scalar', 'fill_value')

    if not (isinstance(axis, types.Omitted) or axis == 0):
        ty_checker.raise_exc(axis, 'int', 'axis')

    self_is_series, other_is_series = isinstance(self, SeriesType), isinstance(other, SeriesType)
    if not (self_is_series or other_is_series):
        return None

    if not isinstance(self, SeriesType):
        ty_checker.raise_exc(self, 'pandas.series', 'self')

    if not isinstance(other, (SeriesType, types.Number, types.UnicodeType)):
        ty_checker.raise_exc(other, 'pandas.series or scalar', 'other')

    operands_are_series = self_is_series and other_is_series
    if operands_are_series:
        series_indexes_comparable = check_types_comparable(self.index, other.index)
        if not series_indexes_comparable:
            raise TypingError('{} Not implemented for series with not-comparable indexes. \
            Given: self.index={}, other.index={}'.format(_func_name, self.index, other.index))

    series_data_comparable = check_types_comparable(self, other)
    if not series_data_comparable:
        raise TypingError('{} Not supported for not-comparable operands. \
        Given: self={}, other={}'.format(_func_name, self, other))

    # specializations for both numeric and string series
    def series_comp_binop_wrapper(self, other, level=None, fill_value=None, axis=0):
        return sdc_comp_binop(self, other, fill_value)

    return series_comp_binop_wrapper
def hpat_pandas_series_rolling_count(self):

    ty_checker = TypeChecker('Method rolling.count().')
    ty_checker.check(self, SeriesRollingType)

    return sdc_pandas_series_rolling_count_impl
def hpat_pandas_series_rolling_corr(self, other=None, pairwise=None):

    ty_checker = TypeChecker('Method rolling.corr().')
    ty_checker.check(self, SeriesRollingType)

    accepted_other = (bool, Omitted, NoneType, SeriesType)
    if not isinstance(other, accepted_other) and other is not None:
        ty_checker.raise_exc(other, 'Series', 'other')

    accepted_pairwise = (bool, Boolean, Omitted, NoneType)
    if not isinstance(pairwise, accepted_pairwise) and pairwise is not None:
        ty_checker.raise_exc(pairwise, 'bool', 'pairwise')

    nan_other = isinstance(other, (Omitted, NoneType)) or other is None

    def hpat_pandas_rolling_series_corr_impl(self, other=None, pairwise=None):
        win = self._window
        minp = self._min_periods

        main_series = self._data
        main_arr = main_series._data

        if nan_other == True:  # noqa
            other_arr = main_arr
        else:
            other_arr = other._data

        main_arr_length = len(main_arr)
        other_arr_length = len(other_arr)
        min_length = min(main_arr_length, other_arr_length)
        length = max(main_arr_length, other_arr_length)
        output_arr = numpy.empty(length, dtype=float64)

        chunks = parallel_chunks(length)
        for i in prange(len(chunks)):
            chunk = chunks[i]
            nfinite = 0
            result = (0., 0., 0., 0., 0.)

            if win == 0:
                for idx in range(chunk.start, chunk.stop):
                    output_arr[idx] = corr_result_or_nan(nfinite, minp, result)
                continue

            prelude_start = max(0, chunk.start - win + 1)
            prelude_stop = min(chunk.start, min_length)

            interlude_start = chunk.start
            interlude_stop = min(prelude_start + win, chunk.stop, min_length)

            postlude_start = min(prelude_start + win, chunk.stop)
            postlude_stop = min(chunk.stop, min_length)

            for idx in range(prelude_start, prelude_stop):
                x, y = main_arr[idx], other_arr[idx]
                nfinite, result = put_corr(x, y, nfinite, result)

            for idx in range(interlude_start, interlude_stop):
                x, y = main_arr[idx], other_arr[idx]
                nfinite, result = put_corr(x, y, nfinite, result)
                output_arr[idx] = corr_result_or_nan(nfinite, minp, result)

            for idx in range(postlude_start, postlude_stop):
                put_x, put_y = main_arr[idx], other_arr[idx]
                pop_x, pop_y = main_arr[idx - win], other_arr[idx - win]
                nfinite, result = put_corr(put_x, put_y, nfinite, result)
                nfinite, result = pop_corr(pop_x, pop_y, nfinite, result)
                output_arr[idx] = corr_result_or_nan(nfinite, minp, result)

            last_start = max(min_length, interlude_start)
            for idx in range(last_start, postlude_start):
                output_arr[idx] = corr_result_or_nan(nfinite, minp, result)

            last_start = max(min_length, postlude_start)
            last_stop = min(min_length + win, chunk.stop)
            for idx in range(last_start, last_stop):
                x, y = main_arr[idx - win], other_arr[idx - win]
                nfinite, result = pop_corr(x, y, nfinite, result)
                output_arr[idx] = corr_result_or_nan(nfinite, minp, result)

            for idx in range(last_stop, chunk.stop):
                output_arr[idx] = numpy.nan

        return pandas.Series(output_arr)

    return hpat_pandas_rolling_series_corr_impl
def hpat_pandas_series_rolling_median(self):

    ty_checker = TypeChecker('Method rolling.median().')
    ty_checker.check(self, SeriesRollingType)

    return hpat_pandas_rolling_series_median_impl