Skip to content

Commit 825486a

Browse files
committed
Refactor
1 parent a9d25bd commit 825486a

File tree

6 files changed

+9
-8
lines changed

6 files changed

+9
-8
lines changed

Diff for: xrspatial/tests/general_checks.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import dask.array as da
22
import numpy as np
3+
import pytest
34
import xarray as xr
45

56
from xrspatial.utils import ArrayTypeFunctionMapping, has_cuda_and_cupy
67

7-
88
# Use this as a decorator to skip tests if do not have both CUDA and CuPy available.
99
cuda_and_cupy_available = pytest.mark.skipif(
1010
not has_cuda_and_cupy(), reason="Requires CUDA and CuPy")

Diff for: xrspatial/tests/test_classify.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from xrspatial import binary, equal_interval, natural_breaks, quantile, reclassify
66
from xrspatial.tests.general_checks import (create_test_raster, cuda_and_cupy_available,
77
general_output_checks)
8-
from xrspatial.utils import doesnt_have_cuda
98

109

1110
def input_data(backend='numpy'):
@@ -45,15 +44,15 @@ def test_binary_dask_numpy(result_binary):
4544
general_output_checks(dask_agg, dask_result, expected_result)
4645

4746

48-
@pytest.mark.skipif(doesnt_have_cuda(), reason="CUDA Device not Available")
49-
def test_binary_cupy(result_reclassify):
47+
@cuda_and_cupy_available
48+
def test_binary_cupy(result_binary):
5049
values, expected_result = result_binary
5150
cupy_agg = input_data(backend='cupy')
5251
cupy_result = binary(cupy_agg, values)
5352
general_output_checks(cupy_agg, cupy_result, expected_result)
5453

5554

56-
@pytest.mark.skipif(doesnt_have_cuda(), reason="CUDA Device not Available")
55+
@cuda_and_cupy_available
5756
def test_binary_dask_cupy(result_binary):
5857
values, expected_result = result_binary
5958
dask_cupy_agg = input_data(backend='dask+cupy')

Diff for: xrspatial/tests/test_hillshade.py

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from xrspatial.tests.general_checks import (assert_numpy_equals_cupy,
88
assert_numpy_equals_dask_numpy, create_test_raster,
99
cuda_and_cupy_available, general_output_checks)
10-
from xrspatial.utils import doesnt_have_cuda
1110

1211
from ..gpu_rtx import has_rtx
1312

Diff for: xrspatial/tests/test_terrain.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import dask.array as da
12
import numpy as np
23
import xarray as xr
34

Diff for: xrspatial/tests/test_zonal.py

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from xrspatial import zonal_crosstab as crosstab
1111
from xrspatial import zonal_stats as stats
1212
from xrspatial.zonal import regions
13+
1314
from .general_checks import create_test_raster, has_cuda_and_cupy
1415

1516

Diff for: xrspatial/viewshed.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
from math import atan, fabs
22
from math import pi as PI
33
from math import sqrt
4-
import numpy as np
54
from typing import Union
5+
6+
import numpy as np
67
import xarray
78

8-
from .utils import has_cuda_and_cupy, is_cupy_array, ngjit
99
from .gpu_rtx import has_rtx
10+
from .utils import has_cuda_and_cupy, is_cupy_array, ngjit
1011

1112
E_ROW_ID = 0
1213
E_COL_ID = 1

0 commit comments

Comments
 (0)