(pop, put, init_result=numpy.nan)
return impl
Generate series rolling min/max implementations based on pop/put funcs
Generate series rolling min/max implementations based on pop/put funcs
Generate series rolling min / max implementations based on pop / put funcs
def gen_sdc_pandas_series_rolling_minmax_impl(pop, put, init_result=numpy.nan):
    """Generate series rolling min/max implementations based on pop/put funcs"""
    def impl(self):
        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)

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

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

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

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

            for idx in range(prelude_start, prelude_stop):
                value = input_arr[idx]
                nfinite, result = put(value, nfinite, result)

            for idx in range(interlude_start, interlude_stop):
                value = input_arr[idx]
                nfinite, result = put(value, nfinite, result)
                output_arr[idx] = result_or_nan(nfinite, minp, result)

            for idx in range(interlude_stop, chunk.stop):
                put_value = input_arr[idx]
                pop_value = input_arr[idx - win]
                nfinite, result = put(put_value, nfinite, result)
                nfinite, result = pop(pop_value, nfinite, result,
                                      input_arr, idx, win)
                output_arr[idx] = result_or_nan(nfinite, minp, result)

        return pandas.Series(output_arr, input_series._index,
                             name=input_series._name)
    return impl
def gen_sdc_pandas_series_rolling_minmax_impl ( pop , put , init_result = numpy . nan ) : def impl ( self ) : 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 ) chunks = parallel_chunks ( length ) for i in prange ( len ( chunks ) ) : chunk = chunks [ i ] nfinite = 0 result = init_result if win == 0 : for idx in range ( chunk . start , chunk . stop ) : output_arr [ idx ] = result_or_nan ( nfinite , minp , result ) continue prelude_start = max ( 0 , chunk . start - win + 1 ) prelude_stop = chunk . start interlude_start = prelude_stop interlude_stop = min ( prelude_start + win , chunk . stop ) for idx in range ( prelude_start , prelude_stop ) : value = input_arr [ idx ] nfinite , result = put ( value , nfinite , result ) for idx in range ( interlude_start , interlude_stop ) : value = input_arr [ idx ] nfinite , result = put ( value , nfinite , result ) output_arr [ idx ] = result_or_nan ( nfinite , minp , result ) for idx in range ( interlude_stop , chunk . stop ) : put_value = input_arr [ idx ] pop_value = input_arr [ idx - win ] nfinite , result = put ( put_value , nfinite , result ) nfinite , result = pop ( pop_value , nfinite , result , input_arr , idx , win ) output_arr [ idx ] = result_or_nan ( nfinite , minp , result ) return pandas . Series ( output_arr , input_series . _index , name = input_series . _name ) return impl