Skip to content

Commit

Permalink
bug: fix nans in Spread
Browse files Browse the repository at this point in the history
This commit fixes a problem introduced in Spread with latest versions
of numba. This is due to the way we used to handle nans, a much cleaner
way is used now with math.isnan without having to first convert to
integrers.
  • Loading branch information
mrava87 committed Oct 6, 2024
1 parent e804c33 commit 2b33f43
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions pylops/basicoperators/_spread_numba.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import math
import os

from numba import jit, prange
Expand All @@ -21,8 +22,8 @@ def _matvec_numba_table(x, y, dims, interp, table, dtable):
dindices = dtable[ix0, it]

for i, indexfloat in enumerate(indices):
index = int(indexfloat)
if index != -9223372036854775808: # =int(np.nan)
if not math.isnan(indexfloat):
index = int(indexfloat)
if not interp:
y[i, index] += x[ix0, it]
else:
Expand All @@ -45,8 +46,8 @@ def _rmatvec_numba_table(x, y, dims, dimsd, interp, table, dtable):
dindices = dtable[ix0, it]

for i, indexfloat in enumerate(indices):
index = int(indexfloat)
if index != -9223372036854775808: # =int(np.nan)
if not math.isnan(indexfloat):
index = int(indexfloat)
if not interp:
y[ix0, it] += x[i, index]
else:
Expand All @@ -71,8 +72,8 @@ def _matvec_numba_onthefly(x, y, dims, interp, fh):
else:
indices, dindices = fh(ix0, it)
for i, indexfloat in enumerate(indices):
index = int(indexfloat)
if index != -9223372036854775808: # =int(np.nan)
if not math.isnan(indexfloat):
index = int(indexfloat)
if not interp:
y[i, index] += x[ix0, it]
else:
Expand All @@ -95,8 +96,8 @@ def _rmatvec_numba_onthefly(x, y, dims, dimsd, interp, fh):
else:
indices, dindices = fh(ix0, it)
for i, indexfloat in enumerate(indices):
index = int(indexfloat)
if index != -9223372036854775808: # =int(np.nan)
if not math.isnan(indexfloat):
index = int(indexfloat)
if not interp:
y[ix0, it] += x[i, index]
else:
Expand Down

0 comments on commit 2b33f43

Please sign in to comment.