Skip to content

Commit

Permalink
Fix cython's buf. mismatch with numpy's 8bit bools
Browse files Browse the repository at this point in the history
  • Loading branch information
LSchueler committed Jul 8, 2024
1 parent 5e89b43 commit 691ef80
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/gstools/variogram/estimator.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ cimport numpy as np
from libc.math cimport M_PI, acos, atan2, cos, fabs, isnan, pow, sin, sqrt


# numpy's "bool"
ctypedef unsigned char uint8


def set_num_threads(num_threads):
cdef int num_threads_c = 1
if num_threads is None:
Expand Down Expand Up @@ -342,7 +346,7 @@ def structured(

def ma_structured(
const double[:, :] f,
const bint[:, :] mask,
uint8[:, :] mask, # numpy's bools are 8bit vars
str estimator_type='m',
num_threads=None,
):
Expand All @@ -365,7 +369,7 @@ def ma_structured(
for i in range(i_max):
for j in range(j_max):
for k in prange(1, k_max-i):
if not mask[i, j] and not mask[i+k, j]:
if mask[i, j] == 0 and mask[i+k, j] == 0:
counts[k] += 1
variogram[k] += estimator_func(f[i, j] - f[i+k, j])

Expand Down

0 comments on commit 691ef80

Please sign in to comment.