Skip to content

Fix compilation under cython 3. #41530

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

Closed
wants to merge 6 commits into from
Closed
Changes from 2 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
19 changes: 14 additions & 5 deletions pandas/_libs/reduction.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ from pandas._libs.util cimport (

from pandas._libs.lib import is_scalar

# Accessing the data member of ndarray is deprecated, but we depend on it.
Copy link
Member

Choose a reason for hiding this comment

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

i guess this adapts to the letter of the deprecation but not the spirit?

cdef extern from *:
"""
static void PyArray_SET_DATA(PyArrayObject *arr, void * data) {
arr->data = data;
}
"""
void PyArray_SET_DATA(ndarray arr, void * data)


cdef cnp.dtype _dtype_obj = np.dtype("object")

Expand Down Expand Up @@ -340,18 +349,18 @@ cdef class Slider:
self.stride = values.strides[0]
self.orig_data = self.buf.data

self.buf.data = self.values.data
PyArray_SET_DATA(self.buf, self.values.data)
self.buf.strides[0] = self.stride

cdef move(self, int start, int end):
"""
For slicing
"""
self.buf.data = self.values.data + self.stride * start
PyArray_SET_DATA(self.buf, self.values.data + self.stride * start)
self.buf.shape[0] = end - start

cdef reset(self):
self.buf.data = self.orig_data
PyArray_SET_DATA(self.buf, self.orig_data)
self.buf.shape[0] = 0


Expand Down Expand Up @@ -469,7 +478,7 @@ cdef class BlockSlider:
arr = self.blk_values[i]

# axis=1 is the frame's axis=0
arr.data = self.base_ptrs[i] + arr.strides[1] * start
PyArray_SET_DATA(arr, self.base_ptrs[i] + arr.strides[1] * start)
arr.shape[1] = end - start

# move and set the index
Expand All @@ -490,7 +499,7 @@ cdef class BlockSlider:
arr = self.blk_values[i]

# axis=1 is the frame's axis=0
arr.data = self.base_ptrs[i]
PyArray_SET_DATA(arr, self.base_ptrs[i])
arr.shape[1] = 0

cdef _restore_blocks(self):
Expand Down