Skip to content

Commit ae16e5e

Browse files
committed
Address review: parametrize dask+cupy descending test, note filter overshoot (#3627)
1 parent 6545a74 commit ae16e5e

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

xrspatial/kde.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,8 @@ def _filter_points_to_tile(xs, ys, ws, tile_x0, tile_y0, dx, dy,
391391
# dx/dy may be negative (descending coordinates), so order the tile
392392
# edges with min/max before widening by the cutoff. The unordered
393393
# version inverted the interval and dropped the points (#3627).
394+
# tile_x1/tile_y1 overshoot the last pixel centre by one spacing,
395+
# which keeps the filter conservative (never drops a contributor).
394396
tile_x1 = tile_x0 + tile_cols * dx
395397
tile_y1 = tile_y0 + tile_rows * dy
396398
x_lo = min(tile_x0, tile_x1) - cutoff

xrspatial/tests/test_kde.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -534,13 +534,17 @@ def test_cupy_matches_numpy(self, point_cluster, simple_grid, kernel):
534534
class TestDaskCupyDescending:
535535
"""dask+cupy must not drop points on descending templates (#3627)."""
536536

537-
def test_dask_cupy_matches_numpy_descending_y(self, point_cluster):
537+
@pytest.mark.parametrize('desc_y,desc_x', [(True, False), (False, True)])
538+
def test_dask_cupy_matches_numpy_descending(self, point_cluster,
539+
desc_y, desc_x):
538540
import cupy
539541
x, y = point_cluster
542+
ys = np.linspace(4, -4, 16) if desc_y else np.linspace(-4, 4, 16)
543+
xs = np.linspace(4, -4, 16) if desc_x else np.linspace(-4, 4, 16)
540544
template = xr.DataArray(
541545
np.zeros((16, 16), dtype=np.float64),
542546
dims=['y', 'x'],
543-
coords={'y': np.linspace(4, -4, 16), 'x': np.linspace(-4, 4, 16)},
547+
coords={'y': ys, 'x': xs},
544548
)
545549
np_result = kde(x, y, bandwidth=1.0, kernel='quartic',
546550
template=template)

0 commit comments

Comments
 (0)