diff --git a/cyarray/carray.pxd.mako b/cyarray/carray.pxd.mako index 72f874c..a9ca9d0 100644 --- a/cyarray/carray.pxd.mako +++ b/cyarray/carray.pxd.mako @@ -40,7 +40,7 @@ cdef class BaseArray: cdef void c_align_array(self, LongArray new_indices, int stride=*) nogil cdef void c_reserve(self, long size) nogil - cdef void c_reset(self) nogil + cdef void c_reset(self) cdef void c_resize(self, long size) nogil cdef void c_squeeze(self) nogil diff --git a/cyarray/carray.pyx.mako b/cyarray/carray.pyx.mako index 3bb236e..1f5c000 100644 --- a/cyarray/carray.pyx.mako +++ b/cyarray/carray.pyx.mako @@ -164,7 +164,7 @@ cdef class BaseArray: cdef void c_reserve(self, long size) nogil: pass - cdef void c_reset(self) nogil: + cdef void c_reset(self): cdef PyArrayObject* arr = self._npy_array self.length = 0 arr.dimensions[0] = self.length @@ -461,12 +461,16 @@ cdef class ${CLASSNAME}(BaseArray): self.alloc = size arr.data = self.data - cdef void c_reset(self) nogil: + cdef void c_reset(self): + cdef np.npy_intp dims = self.length BaseArray.c_reset(self) if self._old_data != NULL: self.data = self._old_data self._old_data = NULL - self._npy_array.data = self.data + + self._npy_array = PyArray_SimpleNewFromData( + 1, &dims, ${NUMPY_TYPENAME}, self.data + ) cdef void c_resize(self, long size) nogil: cdef PyArrayObject* arr = self._npy_array diff --git a/pyproject.toml b/pyproject.toml index b53d030..6eb1fc9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,6 +3,6 @@ requires = [ "wheel>=0.29.0", "setuptools>=42.0.0", "oldest-supported-numpy", - "Cython<3.0", + "Cython", "mako" ] \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 3b2a031..0926b8a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -Cython<3.0 +Cython setuptools>=6.0 numpy mako diff --git a/setup.py b/setup.py index bcf12ab..3801e83 100644 --- a/setup.py +++ b/setup.py @@ -87,7 +87,7 @@ def setup_package(): # The requirements. install_requires = [ - 'numpy', 'mako', 'Cython<3.0', 'setuptools>=6.0' + 'numpy', 'mako', 'Cython', 'setuptools>=6.0' ] tests_require = ["pytest", "pytest-benchmark[histogram]"] docs_require = ["sphinx"]