Skip to content

Commit a2672d7

Browse files
committed
Merge remote-tracking branch 'origin/main' into issue-3561
2 parents f8eda9d + 2b48c7b commit a2672d7

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

benchmarks/rasterizer_benchmarks.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,27 @@
2121

2222
import numpy as np
2323
import geopandas as gpd
24-
import spatialpandas
2524
from rasterio.features import rasterize as rio_rasterize
2625
from rasterio.transform import from_bounds
2726
from shapely.geometry import (
2827
Point, Polygon, MultiPolygon, LineString, MultiLineString, MultiPoint,
2928
box,
3029
)
3130

32-
import datashader as ds
3331
from geocube.api.core import make_geocube
3432
from xrspatial.rasterize import rasterize as xrs_rasterize
3533

34+
# datashader is a deliberate A/B comparison here but is no longer a default
35+
# dependency. Guard the import (and spatialpandas, which only feeds the
36+
# datashader path) so the benchmark still runs when it is absent; the
37+
# datashader column is skipped in that case.
38+
try:
39+
import datashader as ds
40+
import spatialpandas
41+
HAS_DATASHADER = True
42+
except ImportError:
43+
HAS_DATASHADER = False
44+
3645

3746
# ---------------------------------------------------------------------------
3847
# Geometry generators
@@ -598,7 +607,7 @@ def main():
598607
for gen_name, gen_cfg in GENERATORS.items():
599608
gen_fn = gen_cfg["fn"]
600609
kind = gen_cfg["kind"]
601-
use_datashader = kind == "polygon"
610+
use_datashader = kind == "polygon" and HAS_DATASHADER
602611

603612
for n in feature_counts:
604613
geoms, vals = gen_fn(n, rng)

0 commit comments

Comments
 (0)