Skip to content

Commit

Permalink
Use PyArray_SetBaseObject as ndarray.base is readonly property (#201)
Browse files Browse the repository at this point in the history
  • Loading branch information
rafalstapinski authored Apr 27, 2023
1 parent 4c4d202 commit 99e0b1d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions rawpy/_rawpy.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ cdef class RawPy:
# ndarr must hold a reference to this object,
# otherwise the underlying data gets lost when the RawPy instance gets out of scope
# (which would trigger __dealloc__)
ndarr.base = <PyObject*> self
np.PyArray_SetBaseObject(ndarr, self)
# Python doesn't know about above assignment as it's in C-level
Py_INCREF(self)
return ndarr
Expand Down Expand Up @@ -1188,7 +1188,7 @@ cdef class processed_image_wrapper:
ndarr = np.PyArray_SimpleNewFromData(3, shape,
np.NPY_UINT8 if self.processed_image.bits == 8 else np.NPY_UINT16,
self.processed_image.data)
ndarr.base = <PyObject*> self
np.PyArray_SetBaseObject(ndarr, self)
# Python doesn't know about above assignment as it's in C-level
Py_INCREF(self)
return ndarr
Expand Down
4 changes: 2 additions & 2 deletions rawpy/enhance.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def _find_bad_pixel_candidates_bayer2x2(raw, isCandidateFn):
median_ = partial(cv2.medianBlur, ksize=r)
else:
kernel = np.ones((r,r))
median_ = partial(median, selem=kernel)
median_ = partial(median, footprint=kernel)

coords = []

Expand Down Expand Up @@ -265,7 +265,7 @@ def _repair_bad_pixels_bayer2x2(raw, coords, method='median'):
median_ = partial(cv2.medianBlur, ksize=r)
else:
kernel = np.ones((r,r))
median_ = partial(median, selem=kernel)
median_ = partial(median, footprint=kernel)

# we have 4 colors (two greens are always seen as two colors)
for offset_y in [0,1]:
Expand Down

0 comments on commit 99e0b1d

Please sign in to comment.