From 2b3e4d301ed46d35b299df9061f01cd7eaaa3e4b Mon Sep 17 00:00:00 2001 From: Saransh Singh Date: Wed, 13 Nov 2024 15:46:20 -0800 Subject: [PATCH 1/2] cast only non-nan numbers to integers. Suppresses an annoying error that kept popping up. --- hexrd/gridutil.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hexrd/gridutil.py b/hexrd/gridutil.py index 5958cdfe4..cb51c9a40 100644 --- a/hexrd/gridutil.py +++ b/hexrd/gridutil.py @@ -87,7 +87,9 @@ def cellIndices(edges, points_1d): # idx[off_lo] = np.nan # if np.any(off_hi): # idx[off_hi] = np.nan - return np.array(idx, dtype=int) + idx = np.array(idx) + idx[np.isnan(idx)] = 0 + return np.array(idx).astype(int) @numba.njit(nogil=True, cache=True) From c73a96e36ba0c94d330d0adc16bdc89c7d3a53ee Mon Sep 17 00:00:00 2001 From: Saransh Date: Fri, 15 Nov 2024 12:04:33 -0800 Subject: [PATCH 2/2] Update hexrd/gridutil.py Co-authored-by: Patrick Avery --- hexrd/gridutil.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/hexrd/gridutil.py b/hexrd/gridutil.py index cb51c9a40..22ff4eb0f 100644 --- a/hexrd/gridutil.py +++ b/hexrd/gridutil.py @@ -87,9 +87,8 @@ def cellIndices(edges, points_1d): # idx[off_lo] = np.nan # if np.any(off_hi): # idx[off_hi] = np.nan - idx = np.array(idx) - idx[np.isnan(idx)] = 0 - return np.array(idx).astype(int) + idx[np.isnan(idx)] = -1 + return idx.astype(int) @numba.njit(nogil=True, cache=True)