Skip to content

viewshed() output .name and dtype differ across backends #2743

@brendancol

Description

@brendancol

Describe the bug

viewshed() returns a DataArray whose .name and dtype depend on which backend ran, even when the input is identical. For an input DataArray named elevation:

  • numpy: .name is None, dtype float64
  • cupy (RTX): .name is hardcoded to "viewshed", dtype float32
  • cupy + max_distance: .name is None, dtype float64
  • dask+numpy / dask+cupy (in-memory tier): .name is the dask graph token (e.g. array-ffa3..., concatenate-be6...), and dtype is float32 when the GPU tier ran, else float64

There are two distinct problems:

  1. The output name is not set consistently. The CPU path leaves it None, the RTX path hardcodes "viewshed", and the dask paths leak the internal dask graph token because the output DataArray is built without an explicit name=.
  2. The output dtype is float32 on the GPU/RTX exact path but float64 everywhere else.

Sibling modules (slope, curvature, hillshade) already take a name= parameter, pass it through to the output, and keep dtype consistent across numpy and cupy. viewshed() does neither.

Expected behavior

For the same input, viewshed() should return a DataArray with the same .name and the same dtype no matter which backend ran. Matching the sibling modules: add a name= parameter (default None), set the output name from it on every backend, and return float64 on all backends.

Additional context

Found by the /deep-sweep metadata propagation sweep on the viewshed module. Severity MEDIUM (Cat 5, backend-inconsistent metadata). attrs, coords, and dims are preserved correctly on every backend; only .name and output dtype drift.

Metadata

Metadata

Assignees

No one assigned

    Labels

    apiAPI design and consistencybugSomething isn't workinggpuCuPy / CUDA GPU supportviewshed tools

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions