Skip to content

Commit af908e7

Browse files
committed
Attempt to fix expand_dims view (issue #478)
1 parent eec7a47 commit af908e7

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ else()
5050
include(FetchContent)
5151
FetchContent_Declare(blosc2
5252
GIT_REPOSITORY https://github.com/Blosc/c-blosc2
53-
GIT_TAG 82a85f9d285d7ae6d141c73e84c7574bfc24a134 # v2.21.2
53+
GIT_TAG ab7a0cc3b5ca3cf09c5ddaeb66ba1100c1986f23 # fix view
5454
)
5555
FetchContent_MakeAvailable(blosc2)
5656
include_directories("${blosc2_SOURCE_DIR}/include")

src/blosc2/blosc2_ext.pyx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ from cpython cimport (
2424
PyObject_GetBuffer,
2525
)
2626
from cpython.pycapsule cimport PyCapsule_GetPointer, PyCapsule_New
27+
from cpython.ref cimport Py_INCREF, Py_DECREF
2728
from cython.operator cimport dereference
2829
from libc.stdint cimport uintptr_t
2930
from libc.stdlib cimport free, malloc, realloc
@@ -2996,5 +2997,8 @@ def expand_dims(arr1: NDArray, axis_mask: list[bool], final_dims: int) -> blosc2
29962997
mask_[i] = axis_mask[i]
29972998
_check_rc(b2nd_expand_dims(arr1.array, &view, mask_, final_dims),"Error while expanding the arrays")
29982999

3000+
# Increase the reference count of the original array
3001+
Py_INCREF(arr1)
3002+
29993003
return blosc2.NDArray(_schunk=PyCapsule_New(view.sc, <char *> "blosc2_schunk*", NULL),
3000-
_array=PyCapsule_New(view, <char *> "b2nd_array_t*", NULL))
3004+
_array=PyCapsule_New(view, <char *> "b2nd_array_t*", NULL))

0 commit comments

Comments
 (0)