From 355db014f45fc9767428a29c3fe02b88e364115b Mon Sep 17 00:00:00 2001 From: Hendrik Kok Date: Thu, 29 Jun 2023 16:54:47 +0200 Subject: [PATCH] fix for out of bounds neighbour if source and target midpoints are equal --- xugrid/regrid/structured.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xugrid/regrid/structured.py b/xugrid/regrid/structured.py index c56d52533..7dedbf656 100644 --- a/xugrid/regrid/structured.py +++ b/xugrid/regrid/structured.py @@ -263,10 +263,10 @@ def compute_distance_to_centroids( source_midpoint_index = self.maybe_reverse_index(source_index) target_midpoints_index = other.maybe_reverse_index(target_index) neighbor = np.ones(target_midpoints_index.size, dtype=int) - # cases where midpoint target < midpoint source + # cases where midpoint target <= midpoint source condition = ( other.midpoints[target_midpoints_index] - < self.midpoints[source_midpoint_index] + <= self.midpoints[source_midpoint_index] ) neighbor[condition] = -neighbor[condition]