Skip to content

Add degenerate-shape (1x1 / 1xN / Nx1) test coverage for D8 hydro functions #2713

@brendancol

Description

@brendancol

Summary

Four D8 hydrology functions have no tests for degenerate raster shapes: 1x1 single-pixel, 1xN single-row, and Nx1 single-column inputs. The functions are flow_accumulation_d8, flow_direction_d8, flow_length_d8, and hand_d8. On these shapes every cell sits on the kernel boundary, so they exercise a different path than interior cells.

The other D8 variants already cover single-pixel or strip inputs: sink, stream_link, stream_order, snap_pour_point, watershed, basin, fill, flow_path, and twi. These four are the gap.

Current behavior

None of the four raise on these shapes:

  • flow_direction_d8 returns an all-NaN array of the same shape, since every cell is an edge cell.
  • flow_accumulation_d8, flow_length_d8, and hand_d8 return finite values of the matching shape.

This is not a bug. The functions work. The behavior is just untested, so a regression in the boundary handling would slip through.

Proposed change

Add tests only, no source changes. Lock in the current behavior for these four functions on the numpy backend, parametrized over (1,1), (1,N), and (N,1). Check that the output shape matches the input and that the edge behavior holds: all-NaN for flow_direction_d8, finite for the other three.

Found during a test-coverage sweep of the hydro-d8 module.

Metadata

Metadata

Assignees

No one assigned

    Labels

    QA/QCtestsTest coverage and parity

    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