Skip to content

Add multispectral test coverage for true_color edges and evi/savi validation#3436

Open
brendancol wants to merge 3 commits into
mainfrom
deep-sweep-test-coverage-multispectral-2026-06-20
Open

Add multispectral test coverage for true_color edges and evi/savi validation#3436
brendancol wants to merge 3 commits into
mainfrom
deep-sweep-test-coverage-multispectral-2026-06-20

Conversation

@brendancol

Copy link
Copy Markdown
Contributor

Closes #3431

Test-only additions found by /sweep-test-coverage. No source changes.

  • true_color NaN / nodata alpha mask: both legs of isnan(r) OR r <= nodata now checked on numpy, dask+numpy, cupy, and dask+cupy.
  • true_color all-equal input: exercises the range_val != 0 divide-by-zero guard in _normalize_data_cpu.
  • true_color non-default nodata / c / th: confirms the parameters change the output.
  • evi validation guards: non-numeric c1/c2, soil_factor outside [-1, 1], gain < 0.
  • savi soil_factor out-of-range.

Backend coverage: the true_color NaN/alpha test runs on numpy, dask+numpy, cupy, and dask+cupy. The remaining new tests are backend-agnostic (validation guards) or CPU + dask (true_color edges).

Test plan

  • pytest xrspatial/tests/test_multispectral.py for the new tests passes locally
  • cupy and dask+cupy variants executed locally (CUDA available), not skipped

…idation (#3431)

Cover previously-untested branches found by /sweep-test-coverage:
- true_color NaN/nodata alpha mask across numpy/dask+numpy/cupy/dask+cupy
- true_color all-equal input (range_val==0 divide-by-zero guard)
- true_color non-default nodata/c/th parameters
- evi validation guards (c1/c2 numeric, soil_factor range, gain>=0)
- savi soil_factor out-of-range

Test-only; no source changes. GPU variants executed locally (CUDA available).

@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 multispectral test coverage for true_color edges and evi/savi validation

Test-only PR. No source changes. The new tests target branches the sweep flagged as never exercised, and I confirmed each one is real by running the paths locally.

Blockers

None.

Suggestions

None.

Nits

  • test_true_color_all_equal_input on the dask+numpy backend emits a RuntimeWarning: invalid value encountered in cast at compute time. The eager true_color path silences this with warnings.catch_warnings(), but the dask path casts lazily so the warning escapes to the test. It is benign (NaN to uint8 is exactly the behavior being asserted), but if you want a clean test log you could filter it with pytest.warns or warnings.simplefilter('ignore'). Not required.

What looks good

  • The NaN/alpha test drives both legs of isnan(r) OR r <= nodata with one fixture (a NaN cell and a 1.0 <= nodata cell) and runs on all four backends, so the cupy and dask+cupy alpha paths are covered too.
  • The all-equal test pins down the range_val != 0 false branch, which was the one divide-by-zero guard with no coverage.
  • The evi/savi validation tests match the exact error strings in the source, so a reworded guard will surface here rather than silently passing.
  • Parametrizing soil_factor at both 1.5 and -1.5 covers both sides of the range check.

Checklist

  • Algorithm matches reference: n/a (test-only)
  • All implemented backends consistent: true_color NaN test covers all four; validation tests are backend-agnostic
  • NaN handling correct: yes, that is the point of the alpha test
  • Edge cases covered: all-equal/zero-range and NaN both added
  • Dask chunk boundaries: true_color is per-pixel, no neighborhood
  • No premature materialization: compute only at assert time in tests
  • Benchmark: not needed (test-only)
  • README matrix: not needed (no new function)
  • Docstrings present: n/a

@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.

Follow-up review

Re-reviewed after commit fae6e46.

Disposition of prior findings

  • Nit (dask invalid value encountered in cast RuntimeWarning): fixed. Moved the filter into the shared _true_color_to_numpy helper so every true_color test silences the expected NaN->uint8 cast at compute time. Verified with pytest -W error::RuntimeWarning -- the new tests pass with RuntimeWarning promoted to an error.

No new findings. Full test_multispectral.py passes (169 tests, GPU variants included on this CUDA host).

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.

test coverage: untested branches in multispectral.py (true_color NaN/all-equal/params, evi & savi validation)

1 participant