Skip to content

Commit

Permalink
chore(bump cython): fn c_reset fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
nauaneed committed Aug 13, 2024
1 parent 5cc4c5d commit e6ebe8b
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion cyarray/carray.pxd.mako
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 7 additions & 3 deletions cyarray/carray.pyx.mako
Original file line number Diff line number Diff line change
Expand Up @@ -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 = <PyArrayObject*>self._npy_array
self.length = 0
arr.dimensions[0] = self.length
Expand Down Expand Up @@ -461,12 +461,16 @@ cdef class ${CLASSNAME}(BaseArray):
self.alloc = size
arr.data = <char *>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 = <char *>self.data

self._npy_array = PyArray_SimpleNewFromData(
1, &dims, ${NUMPY_TYPENAME}, self.data
)

cdef void c_resize(self, long size) nogil:
cdef PyArrayObject* arr = <PyArrayObject*>self._npy_array
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ requires = [
"wheel>=0.29.0",
"setuptools>=42.0.0",
"oldest-supported-numpy",
"Cython<3.0",
"Cython",
"mako"
]
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Cython<3.0
Cython
setuptools>=6.0
numpy
mako
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down

0 comments on commit e6ebe8b

Please sign in to comment.