Skip to content

help() on .xrs accessor methods shows no docstring (and 17 hydro accessor methods are broken) #2981

@brendancol

Description

@brendancol

What happens

help(arr.xrs.slope) shows a bare slope(**kwargs) with no parameter docs, while help(slope) (from from xrspatial import slope) shows the full docstring. The .xrs accessor methods are thin wrappers that delegate to the standalone functions but carry no docstrings of their own, so anyone exploring the API through the accessor gets nothing useful.

What I'd expect

help(arr.xrs.slope) should show the same documentation as help(slope) — the parameters, notes, and examples.

A bug I hit while looking into this

17 hydrology accessor methods raise ModuleNotFoundError when called. They still import from per-algorithm modules (from .fill import fill, .watershed, .basin, and so on) that were consolidated into xrspatial/hydro.py. Nothing in the accessor tests calls them, so it slipped through.

Affected: flow_direction, flow_direction_dinf, flow_direction_mfd, flow_accumulation, flow_accumulation_mfd, watershed, basin, basins, sink, fill, stream_order, stream_link, snap_pour_point, flow_path, flow_length, twi, hand.

import numpy as np, xarray as xr, xrspatial
da = xr.DataArray(np.abs(np.random.rand(8, 8)) * 100, dims=['y', 'x'],
                  coords={'y': np.arange(8.), 'x': np.arange(8.)})
da.xrs.fill()   # ModuleNotFoundError: No module named 'xrspatial.fill'

Fix

Repoint the broken hydrology delegations at xrspatial.hydro, then copy each standalone function's docstring onto its accessor method so help() works. The hydrology unified wrappers only carry a generic dispatcher docstring, so for those, take the help text from the documented default-algorithm *_d8 variants instead. Add accessor tests for both the docstrings and the hydrology calls.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:hydrologyArea: hydrologybugSomething isn't workingenhancementNew feature or request

    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