Skip to content

Commit

Permalink
Support for new cupy zonal tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ianthomas23 committed Feb 21, 2022
1 parent 9829474 commit bd2b5eb
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions xrspatial/tests/test_zonal.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from xrspatial import trim
from xrspatial import crop
from xrspatial.zonal import regions
from xrspatial.utils import doesnt_have_cuda
from .general_checks import has_cuda_and_cupy


from xrspatial.tests.general_checks import create_test_raster
Expand Down Expand Up @@ -173,16 +173,16 @@ def check_results(backend, df_result, expected_results_dict):

@pytest.mark.parametrize("backend", ['numpy', 'dask+numpy', 'cupy'])
def test_default_stats(backend, data_zones, data_values_2d, result_default_stats):
if backend == 'cupy' and doesnt_have_cuda():
pytest.skip("CUDA Device not Available")
if backend == 'cupy' and not has_cuda_and_cupy():
pytest.skip("Requires CUDA and CuPy")
df_result = stats(zones=data_zones, values=data_values_2d)
check_results(backend, df_result, result_default_stats)


@pytest.mark.parametrize("backend", ['numpy', 'dask+numpy', 'cupy'])
def test_zone_ids_stats(backend, data_zones, data_values_2d, result_zone_ids_stats):
if backend == 'cupy' and doesnt_have_cuda():
pytest.skip("CUDA Device not Available")
if backend == 'cupy' and not has_cuda_and_cupy():
pytest.skip("Requires CUDA and CuPy")
zone_ids, expected_result = result_zone_ids_stats
df_result = stats(zones=data_zones, values=data_values_2d,
zone_ids=zone_ids)
Expand All @@ -192,8 +192,8 @@ def test_zone_ids_stats(backend, data_zones, data_values_2d, result_zone_ids_sta
@pytest.mark.parametrize("backend", ['numpy', 'cupy'])
def test_custom_stats(backend, data_zones, data_values_2d, result_custom_stats):
# ---- custom stats (NumPy and CuPy only) ----
if backend == 'cupy' and doesnt_have_cuda():
pytest.skip("CUDA Device not Available")
if backend == 'cupy' and not has_cuda_and_cupy():
pytest.skip("Requires CUDA and CuPy")

custom_stats = {
'double_sum': _double_sum,
Expand Down

0 comments on commit bd2b5eb

Please sign in to comment.