Skip to content

Commit ab3fdc9

Browse files
committed
Guard shapely import in test_rasterize for CI without shapely (#989)
1 parent 95b8d66 commit ab3fdc9

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

xrspatial/tests/test_rasterize.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,24 @@
22
import numpy as np
33
import pytest
44
import xarray as xr
5-
from shapely.geometry import (
6-
box, Polygon, MultiPolygon, Point, MultiPoint,
7-
LineString, MultiLineString,
8-
)
95

10-
from xrspatial.rasterize import rasterize
6+
try:
7+
from shapely.geometry import (
8+
box, Polygon, MultiPolygon, Point, MultiPoint,
9+
LineString, MultiLineString,
10+
)
11+
has_shapely = True
12+
except ImportError:
13+
has_shapely = False
14+
15+
# Guard the rasterize import too -- it imports numba.cuda at module level
16+
# which is fine, but the tests all need shapely anyway.
17+
if has_shapely:
18+
from xrspatial.rasterize import rasterize
19+
20+
pytestmark = pytest.mark.skipif(
21+
not has_shapely, reason="shapely not installed"
22+
)
1123

1224
# Try importing optional GPU dependencies
1325
try:

0 commit comments

Comments
 (0)