Skip to content

Add missing morphology accessor methods#3409

Open
brendancol wants to merge 3 commits into
mainfrom
deep-sweep-api-consistency-morphology-2026-06-20
Open

Add missing morphology accessor methods#3409
brendancol wants to merge 3 commits into
mainfrom
deep-sweep-api-consistency-morphology-2026-06-20

Conversation

@brendancol

Copy link
Copy Markdown
Contributor

Closes #3399

The .xrs accessor exposed only four of the seven public morphology functions. This adds the missing three to both accessor classes.

  • Add morph_gradient, morph_white_tophat, and morph_black_tophat methods to XrsSpatialDataArrayAccessor and XrsSpatialDatasetAccessor, following the existing forwarding pattern.
  • Add accessor tests for the morphology family (none existed before) and extend the expected-methods checks to guard all seven methods.

The change forwards to the existing morphology functions, so backend coverage matches those: numpy, cupy, dask+numpy, dask+cupy.

Test plan:

  • pytest xrspatial/tests/test_accessor.py (69 passed)
  • New tests assert accessor output is identical to the direct function call for erode, gradient, white_tophat, black_tophat (DataArray) and gradient (Dataset)

Expose morph_gradient, morph_white_tophat, and morph_black_tophat on
both the DataArray and Dataset .xrs accessors, matching the four base
morphology ops already present. Add accessor tests for the morphology
family and guard all seven methods in the expected-methods checks.

@brendancol brendancol left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Review: Add missing morphology accessor methods

Blockers

None.

Suggestions

None.

Nits

None.

What looks good

  • The three new methods follow the existing forwarding pattern byte-for-byte (lazy import, **kwargs passthrough), so they inherit whatever backend support the underlying functions provide.
  • Both accessor classes are updated, so DataArray and Dataset stay in sync.
  • Tests assert the accessor output is identical to the direct function call, which is the right contract for a thin forwarder.
  • The expected-methods checks now list all seven morph methods, so a future regression that drops one gets caught.

Checklist

  • Forwards to existing, already-tested morphology functions; no new algorithm
  • Backend support inherited from the underlying functions (numpy / cupy / dask+numpy / dask+cupy)
  • NaN handling unchanged (delegated)
  • Accessor parity tested for DataArray and Dataset
  • No materialization or copies introduced
  • No benchmark needed (no compute path added)
  • No README/docs change needed (accessor methods are not separately documented)
  • Matches API conventions (mirrors the four existing morph accessor methods)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

morph_gradient, white_tophat, black_tophat missing from .xrs accessor

1 participant