Skip to content

Modernise bump() API and add multi-backend support #907

@brendancol

Description

@brendancol

Problem

bump() in xrspatial/bump.py is inconsistent with every other function in the library:

  1. Wrong input API: Takes raw width/height integers instead of a DataArray template. Every other function takes a DataArray.
  2. No backend dispatch: No ArrayTypeFunctionMapping, no cupy/dask backends — numpy only.
  3. No coordinates on output: Returns a DataArray without coordinate values, making it incompatible with downstream functions that require coordinate information (slope, proximity, etc.).
  4. Performance: The numba-JIT triple-nested loop is O(count × spread²) per bump. Fine for small arrays but slow for large count/spread.

There's even a TODO in the source: "TODO: change parameters to take agg instead of height/width".

Proposed Fix

  • Refactor bump() to accept a template DataArray (matching generate_terrain() pattern).
  • Add ArrayTypeFunctionMapping dispatch with numpy/cupy/dask/dask+cupy backends.
  • For CuPy: @cuda.jit kernel with each thread handling one bump.
  • For dask: map_blocks since each bump's effect is local to its spread radius.
  • Set proper coordinates on the output DataArray.
  • Update README feature matrix.

Breaking Change

The function signature changes from bump(width, height, ...) to accepting a DataArray. Document in changelog.

Metadata

Metadata

Assignees

No one assigned

    Labels

    apiAPI design and consistencybackend-coverageAdding missing dask/cupy/dask+cupy backend supportenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions