Skip to content

Add dask+numpy nodata-masking value-parity tests for resample - #3074

Merged
brendancol merged 1 commit into
mainfrom
deep-sweep-test-coverage-resample-01
Jun 9, 2026
Merged

Add dask+numpy nodata-masking value-parity tests for resample#3074
brendancol merged 1 commit into
mainfrom
deep-sweep-test-coverage-resample-01

Conversation

@brendancol

Copy link
Copy Markdown
Contributor

Closes #3073

What this does

  • Adds xrspatial/tests/test_resample_nodata_dask_parity_3073.py covering the dask+numpy nodata-masking value path, which had no value-level test (existing dask+numpy nodata tests only hit the error paths and identity-attr refresh).
  • Each test asserts the dask+numpy output matches the numpy backend (equal_nan=True) and that the all-sentinel block becomes NaN, across method (nearest, average) and sentinel source (explicit nodata= arg, _FillValue attr, nodata attr; integer -9999 and float -1.0).

Backend coverage

numpy and dask+numpy. cupy / dask+cupy nodata tests are left out on purpose: on xarray 2025.12 + cupy 13.6, DataArray.where() on a cupy array raises AttributeError: module 'cupy' has no attribute 'astype', an xarray/cupy Array-API mismatch (~221 .where sites across xrspatial), not a resample bug.

Scope

Test-only. resample.py is unchanged.

Test plan

  • 10 new tests pass locally (CUDA host)
  • Full test_resample.py + coverage suite still green (309 passed)

@github-actions github-actions Bot added the performance PR touches performance-sensitive code label Jun 9, 2026

@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 dask+numpy nodata-masking value-parity tests for resample

Blockers

None.

Suggestions

None.

Nits

None.

What looks good

  • The isnan(out[0,0]) assertions carry their weight. Without masking the top-left 2x2 sentinel block would average or select to a finite -9999 / -1.0, so the test fails loudly if masking ever silently becomes a no-op.
  • Branch coverage of _apply_nodata_mask is good: the float -1.0 sentinel takes the float-input path (no cast), the int -9999 sentinel takes the integer->float32 cast path.
  • Parity is checked against the numpy backend with equal_nan=True, which is exactly the gap this closes.
  • The cupy exclusion is written into the module docstring with the concrete xarray/cupy error, so a future reader on a fixed environment knows what to re-enable.
  • Filename carries the issue token 3073, so no temp/file collision with parallel runs.

Checklist

  • Backends: numpy + dask+numpy covered; cupy/dask+cupy excluded with a documented reason.
  • NaN handling: masked cells assert NaN; parity uses equal_nan.
  • Edge cases: all-sentinel block (all-NaN window) is exercised on the average path.
  • Source untouched; test-only.
  • No benchmark or README change needed.

@brendancol
brendancol merged commit 70edc91 into main Jun 9, 2026
9 checks passed
@brendancol
brendancol deleted the deep-sweep-test-coverage-resample-01 branch June 25, 2026 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance PR touches performance-sensitive code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

resample: add dask+numpy nodata-masking value-parity tests

1 participant