Skip to content

Commit

Permalink
fix for out of bounds neighbour if source and target midpoints are equal
Browse files Browse the repository at this point in the history
  • Loading branch information
HendrikKok committed Jun 29, 2023
1 parent 9e5db8b commit 355db01
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions xugrid/regrid/structured.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down

0 comments on commit 355db01

Please sign in to comment.