Skip to content

Commit 71e1c4f

Browse files
committed
Use more contiguity
1 parent 8247f82 commit 71e1c4f

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

pandas/_libs/groupby.pyx

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1231,12 +1231,12 @@ def group_min(groupby_t[:, ::1] out,
12311231
@cython.boundscheck(False)
12321232
@cython.wraparound(False)
12331233
cdef group_cummin_max(groupby_t[:, ::1] out,
1234-
ndarray[groupby_t, ndim=2] values,
1235-
uint8_t[:, ::1] mask,
1236-
const intp_t[:] labels,
1237-
int ngroups,
1238-
bint is_datetimelike,
1239-
bint compute_max):
1234+
ndarray[groupby_t, ndim=2] values,
1235+
uint8_t[:, ::1] mask,
1236+
const intp_t[:] labels,
1237+
int ngroups,
1238+
bint is_datetimelike,
1239+
bint compute_max):
12401240
"""
12411241
Cumulative minimum/maximum of columns of `values`, in row groups `labels`.
12421242
@@ -1246,9 +1246,9 @@ cdef group_cummin_max(groupby_t[:, ::1] out,
12461246
Array to store cummin/max in.
12471247
values : array
12481248
Values to take cummin/max of.
1249-
mask : array[uint8_t]
1250-
If `use_mask`, then indices represent missing values,
1251-
otherwise will be passed as a zeroed array
1249+
mask : array[uint8_t] or None
1250+
If not None, indices represent missing values,
1251+
otherwise the mask will not be used
12521252
labels : np.ndarray[np.intp]
12531253
Labels to group by.
12541254
ngroups : int
@@ -1266,16 +1266,14 @@ cdef group_cummin_max(groupby_t[:, ::1] out,
12661266
cdef:
12671267
Py_ssize_t i, j, N, K, size
12681268
groupby_t val, mval
1269-
ndarray[groupby_t, ndim=2] accum
1269+
groupby_t[:, ::1] accum
12701270
intp_t lab
1271-
uint8_t[:, ::1] mask_
12721271
bint val_is_nan, use_mask
12731272

12741273
use_mask = mask is not None
1275-
mask_ = mask if use_mask else np.zeros_like(values, dtype=np.uint8)
12761274

12771275
N, K = (<object>values).shape
1278-
accum = np.empty((ngroups, K), dtype=np.asarray(values).dtype)
1276+
accum = np.empty((ngroups, K), dtype=np.asarray(values).dtype, order='C')
12791277
if groupby_t is int64_t:
12801278
accum[:] = -_int64_max if compute_max else _int64_max
12811279
elif groupby_t is uint64_t:
@@ -1293,7 +1291,7 @@ cdef group_cummin_max(groupby_t[:, ::1] out,
12931291
val_is_nan = False
12941292

12951293
if use_mask:
1296-
if mask_[i, j]:
1294+
if mask[i, j]:
12971295

12981296
# `out` does not need to be set since it
12991297
# will be masked anyway

0 commit comments

Comments
 (0)