Skip to content

REF: Use more memory views in rolling aggregations #37886

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 16, 2020
Merged
Changes from all commits
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
10 changes: 5 additions & 5 deletions pandas/_libs/window/aggregations.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ cdef inline void remove_sum(float64_t val, int64_t *nobs, float64_t *sum_x,
sum_x[0] = t


def roll_sum(ndarray[float64_t] values, ndarray[int64_t] start,
def roll_sum(const float64_t[:] values, ndarray[int64_t] start,
Copy link
Member

Choose a reason for hiding this comment

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

Can start be a memoryview?

Copy link
Member Author

Choose a reason for hiding this comment

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

No (not yet). start/end go through functions that still expect a ndarray.

ndarray[int64_t] end, int64_t minp):
cdef:
float64_t sum_x = 0, compensation_add = 0, compensation_remove = 0
Expand Down Expand Up @@ -240,7 +240,7 @@ cdef inline void remove_mean(float64_t val, Py_ssize_t *nobs, float64_t *sum_x,
neg_ct[0] = neg_ct[0] - 1


def roll_mean(ndarray[float64_t] values, ndarray[int64_t] start,
def roll_mean(const float64_t[:] values, ndarray[int64_t] start,
ndarray[int64_t] end, int64_t minp):
cdef:
float64_t val, compensation_add = 0, compensation_remove = 0, sum_x = 0
Expand Down Expand Up @@ -361,7 +361,7 @@ cdef inline void remove_var(float64_t val, float64_t *nobs, float64_t *mean_x,
ssqdm_x[0] = 0


def roll_var(ndarray[float64_t] values, ndarray[int64_t] start,
def roll_var(const float64_t[:] values, ndarray[int64_t] start,
ndarray[int64_t] end, int64_t minp, int ddof=1):
"""
Numerically stable implementation using Welford's method.
Expand Down Expand Up @@ -772,7 +772,7 @@ def roll_kurt(ndarray[float64_t] values, ndarray[int64_t] start,
# Rolling median, min, max


def roll_median_c(ndarray[float64_t] values, ndarray[int64_t] start,
def roll_median_c(const float64_t[:] values, ndarray[int64_t] start,
ndarray[int64_t] end, int64_t minp):
# GH 32865. win argument kept for compatibility
cdef:
Expand Down Expand Up @@ -1032,7 +1032,7 @@ interpolation_types = {
}


def roll_quantile(ndarray[float64_t, cast=True] values, ndarray[int64_t] start,
def roll_quantile(const float64_t[:] values, ndarray[int64_t] start,
ndarray[int64_t] end, int64_t minp,
float64_t quantile, str interpolation):
"""
Expand Down