Skip to content

edge_detection public API skips _validate_raster #1271

@brendancol

Description

@brendancol

Describe the bug

The five public functions in xrspatial/edge_detection.py (sobel_x, sobel_y, laplacian, prewitt_x, prewitt_y) skip the _validate_raster() check that sibling modules (aspect, slope, curvature, bilateral) run on agg at the top of each public function. Passing a bare np.ndarray raises AttributeError from agg.data instead of a clean TypeError, and a 1-D DataArray fails inside numba/cupy with a confusing message instead of a clean ValueError.

Cat 6 (input validation / dtype confusion) finding from the latest security sweep, severity MEDIUM. Numerical correctness is fine because convolve_2d._promote_float already casts integer dtypes to float32, so this is purely an error-message UX issue.

Expected behavior

Each function should call _validate_raster(agg, func_name='<name>', name='agg') at the top, matching the call style in aspect.py line 400. Non-DataArray input should raise TypeError, wrong-ndim input should raise ValueError.

Additional context

Tests parametrize over float64, so the default numeric=True is fine and does not need to be overridden.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinginput-validationInput validation and error messages

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions