Skip to content

Commit 0ea90cf

Browse files
authored
Merge pull request scipy#21904 from tylerjereddy/treddy_issue_21885
BUG: fix nogil LinearNDInterpolator
2 parents 713c8c4 + 06676d4 commit 0ea90cf

File tree

1 file changed

+20
-18
lines changed

1 file changed

+20
-18
lines changed

scipy/interpolate/_interpnd.pyx

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -336,30 +336,32 @@ class LinearNDInterpolator(NDInterpolatorBase):
336336
eps = 100 * DBL_EPSILON
337337
eps_broad = sqrt(DBL_EPSILON)
338338

339-
with nogil:
340-
for i in range(xi.shape[0]):
339+
# NOTE: a nogil block segfaults here with Python 3.10
340+
# and 3.11 on x86_64 Ubuntu Linux with gcc 9.x and 11.x
341+
# and therefore nogil was disabled to fix gh-21885
342+
for i in range(xi.shape[0]):
341343

342-
# 1) Find the simplex
344+
# 1) Find the simplex
343345

344-
isimplex = qhull._find_simplex(&info, c,
345-
&xi[0,0] + i*ndim,
346-
&start, eps, eps_broad)
346+
isimplex = qhull._find_simplex(&info, c,
347+
&xi[0,0] + i*ndim,
348+
&start, eps, eps_broad)
347349

348-
# 2) Linear barycentric interpolation
349-
350-
if isimplex == -1:
351-
# don't extrapolate
352-
for k in range(nvalues):
353-
out[i,k] = fill_value
354-
continue
350+
# 2) Linear barycentric interpolation
355351

352+
if isimplex == -1:
353+
# don't extrapolate
356354
for k in range(nvalues):
357-
out[i,k] = 0
355+
out[i,k] = fill_value
356+
continue
358357

359-
for j in range(ndim+1):
360-
for k in range(nvalues):
361-
m = simplices[isimplex,j]
362-
out[i,k] = out[i,k] + c[j] * values[m,k]
358+
for k in range(nvalues):
359+
out[i,k] = 0
360+
361+
for j in range(ndim+1):
362+
for k in range(nvalues):
363+
m = simplices[isimplex,j]
364+
out[i,k] = out[i,k] + c[j] * values[m,k]
363365

364366
return out
365367

0 commit comments

Comments
 (0)