cumulative_viewshed allocates its count accumulator as a numpy array on the non-dask path, even when the raster is cupy-backed. viewshed() returns a cupy DataArray for cupy input, so this line adds numpy to cupy and raises TypeError: Unsupported type numpy.ndarray:
count = count + (vs_data != INVISIBLE).astype(np.int32)
visibility_frequency delegates to cumulative_viewshed, so it fails the same way.
Repro:
import numpy as np, xarray as xr, cupy
from xrspatial.visibility import cumulative_viewshed
data = np.random.RandomState(42).rand(15, 15).astype(float) * 100
r = xr.DataArray(data, dims=['y', 'x'],
coords={'y': np.arange(15.), 'x': np.arange(15.)})
r.data = cupy.asarray(data)
cumulative_viewshed(r, [{'x': 7.0, 'y': 7.0, 'observer_elev': 50}]) # TypeError
A flat raster fails earlier inside viewshed for an unrelated reason (OptiX needs positive elevation variance), so the repro uses random terrain.
The fix should allocate count with the same array module as raster.data, or pull vs_data to numpy before accumulating.
Found by the test-coverage sweep. The test PR adds a strict xfail that must be removed when this is fixed.
cumulative_viewshedallocates itscountaccumulator as a numpy array on the non-dask path, even when the raster is cupy-backed.viewshed()returns a cupy DataArray for cupy input, so this line adds numpy to cupy and raisesTypeError: Unsupported type numpy.ndarray:visibility_frequencydelegates tocumulative_viewshed, so it fails the same way.Repro:
A flat raster fails earlier inside
viewshedfor an unrelated reason (OptiX needs positive elevation variance), so the repro uses random terrain.The fix should allocate
countwith the same array module asraster.data, or pullvs_datato numpy before accumulating.Found by the test-coverage sweep. The test PR adds a strict xfail that must be removed when this is fixed.