(other, align_finiteness=False)
return _impl
Generate series.rolling.cov() implementation based on series alignment
Generate series.rolling.cov() implementation based on series alignment
Generate series . rolling . cov () implementation based on series alignment
def _gen_hpat_pandas_rolling_series_cov_impl(other, align_finiteness=False):
    """Generate series.rolling.cov() implementation based on series alignment"""
    nan_other = isinstance(other, (Omitted, NoneType)) or other is None

    def _impl(self, other=None, pairwise=None, ddof=1):
        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.)

            if win == 0:
                for idx in range(chunk.start, chunk.stop):
                    output_arr[idx] = cov_result_or_nan(nfinite, minp, result, ddof)
                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_cov(x, y, nfinite, result,
                                          align_finiteness=align_finiteness)

            for idx in range(interlude_start, interlude_stop):
                x, y = main_arr[idx], other_arr[idx]
                nfinite, result = put_cov(x, y, nfinite, result,
                                          align_finiteness=align_finiteness)
                output_arr[idx] = cov_result_or_nan(nfinite, minp, result, ddof)

            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_cov(put_x, put_y, nfinite, result,
                                          align_finiteness=align_finiteness)
                nfinite, result = pop_cov(pop_x, pop_y, nfinite, result,
                                          align_finiteness=align_finiteness)
                output_arr[idx] = cov_result_or_nan(nfinite, minp, result, ddof)

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

            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_cov(x, y, nfinite, result,
                                          align_finiteness=align_finiteness)
                output_arr[idx] = cov_result_or_nan(nfinite, minp, result, ddof)

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

        return pandas.Series(output_arr)

    return _impl
def _gen_hpat_pandas_rolling_series_cov_impl ( other , align_finiteness = False ) : nan_other = isinstance ( other , ( Omitted , NoneType ) ) or other is None def _impl ( self , other = None , pairwise = None , ddof = 1 ) : 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. ) if win == 0 : for idx in range ( chunk . start , chunk . stop ) : output_arr [ idx ] = cov_result_or_nan ( nfinite , minp , result , ddof ) 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_cov ( x , y , nfinite , result , align_finiteness = align_finiteness ) for idx in range ( interlude_start , interlude_stop ) : x , y = main_arr [ idx ] , other_arr [ idx ] nfinite , result = put_cov ( x , y , nfinite , result , align_finiteness = align_finiteness ) output_arr [ idx ] = cov_result_or_nan ( nfinite , minp , result , ddof ) 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_cov ( put_x , put_y , nfinite , result , align_finiteness = align_finiteness ) nfinite , result = pop_cov ( pop_x , pop_y , nfinite , result , align_finiteness = align_finiteness ) output_arr [ idx ] = cov_result_or_nan ( nfinite , minp , result , ddof ) last_start = max ( min_length , interlude_start ) for idx in range ( last_start , postlude_start ) : output_arr [ idx ] = cov_result_or_nan ( nfinite , minp , result , ddof ) 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_cov ( x , y , nfinite , result , align_finiteness = align_finiteness ) output_arr [ idx ] = cov_result_or_nan ( nfinite , minp , result , ddof ) for idx in range ( last_stop , chunk . stop ) : output_arr [ idx ] = numpy . nan return pandas . Series ( output_arr ) return _impl