Skip to content

Commit

Permalink
fix: precommit
Browse files Browse the repository at this point in the history
  • Loading branch information
ameliefroessl committed Jun 4, 2024
1 parent 331dca7 commit 207f696
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
15 changes: 10 additions & 5 deletions xdem/coreg/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ def _preprocess_coreg_fit(
return ref_elev, tba_elev, inlier_mask, transform, crs


def mask_array(arr: NDArrayf, nodata: int | float):
def mask_array(arr: NDArrayf, nodata: int | float) -> NDArrayf:
"""Convert invalid data to nan."""
return np.where(np.logical_or(~da.isfinite(arr), arr == nodata), np.nan, arr)

Expand Down Expand Up @@ -717,7 +717,9 @@ def _postprocess_coreg_apply_pts(
return applied_elev


def _postprocess_coreg_apply_xarray_xarray(applied_elev: da.Array, out_transform: affine.Affine):
def _postprocess_coreg_apply_xarray_xarray(
applied_elev: da.Array, out_transform: affine.Affine
) -> tuple[da.Array, affine.Affine]:
"""Post-processing and checks of apply for dask inputs."""

# TODO mimic what is happening in the postprocess_coreg_apply_rst.
Expand Down Expand Up @@ -1321,9 +1323,12 @@ def _get_subsample_on_valid_mask(self, valid_mask: NDArrayb, verbose: bool = Fal
def _get_subsample_indices_dask(self, data: NDArrayb) -> tuple[NDArrayf, NDArrayf]:
"""Get subsampled indices from a dask array."""

# subsample value is handled in delyyed_subsample
# subsample value is handled in delayed_subsample
indices = delayed_subsample(
darr=data, subsample=self._meta["subsample"], return_indices=True, silence_max_subsample=True
darr=data,
subsample=self._meta["subsample"],
return_indices=True,
silence_max_subsample=True,
)

# Write final subsample to class
Expand Down Expand Up @@ -1761,7 +1766,7 @@ def _apply_func(self, **kwargs: Any) -> tuple[NDArrayf | gpd.GeoDataFrame, affin
"""Distribute to _apply_rst and _apply_pts based on input and method availability."""

# If input is a raster
if isinstance(kwargs["elev"], np.ndarray):
if isinstance(kwargs["elev"], (np.ndarray, da.Array)):

# See if a _apply_rst exists
try:
Expand Down
6 changes: 5 additions & 1 deletion xdem/coreg/biascorr.py
Original file line number Diff line number Diff line change
Expand Up @@ -1050,7 +1050,11 @@ def _apply_rst(


# TODO move this function somewhere sensible
def meshgrid(_, axis="x", block_info=None):
def meshgrid(
_: NDArrayf | NDArrayb,
block_info: dict[Any, Any],
axis: Literal["x", "y"] = "x",
) -> NDArrayf:
"""A bit of a hack to create a meshgrid for a dask array."""
loc = block_info[0]["array-location"]
mesh = np.meshgrid(np.arange(*loc[1]), np.arange(*loc[0]))
Expand Down

0 comments on commit 207f696

Please sign in to comment.