Skip to content

Commit

Permalink
feat(weighted_median): call 'numpy.import_array()' after cimport
Browse files Browse the repository at this point in the history
  • Loading branch information
ljgray committed Sep 26, 2024
1 parent d5cb01a commit 95ca0d2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions caput/truncate.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ from cython.parallel import prange
import numpy as np
cimport numpy as cnp

# Required for numpy 2.0 compatibility
np.import_array()

cdef extern from "truncate.hpp":
inline int bit_truncate(int val, int err) nogil

Expand Down
3 changes: 3 additions & 0 deletions caput/weighted_median.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ from MedianTree cimport Tree, Data
cimport numpy as np
cimport cython

# Required for numpy 2.0 compatibility
np.import_array()

# Define the fused types that can be used for the data or weights in the median routine
ctypedef fused data_t:
int
Expand Down

0 comments on commit 95ca0d2

Please sign in to comment.