Skip to content

Commit 22d966c

Browse files
authored
Fix support for numpy 2.3+ (#28)
1 parent 617836c commit 22d966c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

PythonAPI/pycocotools/_mask.pyx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ cdef class Masks:
9595
# Create a 1D array, and reshape it to fortran/Matlab column-major array
9696
ndarray = np.PyArray_SimpleNewFromData(1, shape, np.NPY_UINT8, self._mask).reshape((self._h, self._w, self._n), order='F')
9797
# The _mask allocated by Masks is now handled by ndarray
98-
PyArray_ENABLEFLAGS(ndarray, np.NPY_OWNDATA)
98+
PyArray_ENABLEFLAGS(ndarray, np.NPY_ARRAY_OWNDATA)
9999
return ndarray
100100

101101
# internal conversion from Python RLEs object to compressed RLE format
@@ -164,7 +164,7 @@ def area(rleObjs):
164164
shape[0] = <np.npy_intp> Rs._n
165165
a = np.array((Rs._n, ), dtype=np.uint8)
166166
a = np.PyArray_SimpleNewFromData(1, shape, np.NPY_UINT32, _a)
167-
PyArray_ENABLEFLAGS(a, np.NPY_OWNDATA)
167+
PyArray_ENABLEFLAGS(a, np.NPY_ARRAY_OWNDATA)
168168
return a
169169

170170
# iou computation. support function overload (RLEs-RLEs and bbox-bbox).
@@ -236,7 +236,7 @@ def iou( dt, gt, pyiscrowd ):
236236
iou = np.zeros((m*n, ), dtype=np.double)
237237
shape[0] = <np.npy_intp> m*n
238238
iou = np.PyArray_SimpleNewFromData(1, shape, np.NPY_DOUBLE, _iou)
239-
PyArray_ENABLEFLAGS(iou, np.NPY_OWNDATA)
239+
PyArray_ENABLEFLAGS(iou, np.NPY_ARRAY_OWNDATA)
240240
_iouFun(dt, gt, iscrowd, m, n, iou)
241241
return iou.reshape((m,n), order='F')
242242

@@ -249,7 +249,7 @@ def toBbox( rleObjs ):
249249
shape[0] = <np.npy_intp> 4*n
250250
bb = np.array((1,4*n), dtype=np.double)
251251
bb = np.PyArray_SimpleNewFromData(1, shape, np.NPY_DOUBLE, _bb).reshape((n, 4))
252-
PyArray_ENABLEFLAGS(bb, np.NPY_OWNDATA)
252+
PyArray_ENABLEFLAGS(bb, np.NPY_ARRAY_OWNDATA)
253253
return bb
254254

255255
def frBbox(np.ndarray[np.double_t, ndim=2] bb, siz h, siz w ):

0 commit comments

Comments
 (0)