Skip to content

Commit

Permalink
fix(cython): fix numpy 2.0 cimport compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
ljgray committed Jun 17, 2024
1 parent 4ef9b0b commit f548670
Show file tree
Hide file tree
Showing 2 changed files with 7 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
cnp.import_array()

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

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

# Required for numpy >= 2.0
# TODO: not sure if there should be some sort of conditional here
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 f548670

Please sign in to comment.