Skip to content

Commit 9ae244d

Browse files
committed
fixed some tests for cupy available but no dask case
1 parent 03e60fc commit 9ae244d

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

xrspatial/tests/test_focal.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,18 @@ def test_mean_transfer_function_gpu_equals_cpu():
8989
np.testing.assert_allclose(
9090
numpy_mean.data, cupy_mean.data.get(), equal_nan=True)
9191

92+
93+
@dask_array_available
94+
@cuda_and_cupy_available
95+
def test_mean_transfer_dask_gpu_raise_not_implemented():
96+
97+
import cupy
98+
99+
# cupy case
100+
cupy_agg = xr.DataArray(cupy.asarray(data_random))
101+
cupy_mean = mean(cupy_agg)
102+
general_output_checks(cupy_agg, cupy_mean)
103+
92104
# dask + cupy case not implemented
93105
dask_cupy_agg = xr.DataArray(
94106
da.from_array(cupy.asarray(data_random), chunks=(3, 3))
@@ -466,6 +478,7 @@ def test_hotspots_numpy(data_hotspots):
466478
assert numpy_hotspots.attrs['unit'] == '%'
467479

468480

481+
@dask_array_available
469482
def test_hotspots_dask_numpy(data_hotspots):
470483
data, kernel, expected_result = data_hotspots
471484
dask_numpy_agg = create_test_raster(data, backend='dask')
@@ -495,9 +508,3 @@ def test_hotspot_gpu(data_hotspots):
495508
cupy_hotspots[coord].data, cupy_agg[coord].data, equal_nan=True
496509
)
497510
assert cupy_hotspots.attrs['unit'] == '%'
498-
499-
# dask + cupy case not implemented
500-
dask_cupy_agg = create_test_raster(data, backend='dask+cupy')
501-
with pytest.raises(NotImplementedError) as e_info:
502-
hotspots(dask_cupy_agg, kernel)
503-
assert e_info

xrspatial/tests/test_perlin.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ def create_test_arr(backend='numpy'):
2020
raster.data = cupy.asarray(raster.data)
2121

2222
if 'dask' in backend:
23+
import dask.array as da
2324
raster.data = da.from_array(raster.data, chunks=(10, 10))
2425

2526
return raster

xrspatial/tests/test_slope.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ def test_numpy_equals_cupy_qgis_data(elevation_raster):
6868
assert_numpy_equals_cupy(numpy_agg, cupy_agg, slope)
6969

7070

71+
@dask_array_available
7172
@cuda_and_cupy_available
7273
@pytest.mark.parametrize("size", [(2, 4), (10, 15)])
7374
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)