Skip to content

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

@brendancol

Description

@brendancol

Summary

The test-coverage sweep found several untested branches in xrspatial/multispectral.py. The index functions have solid backend and NaN coverage, but a few specific code paths are never exercised by the suite.

Untested paths

  1. true_color NaN handling. The function builds an alpha channel from np.logical_or(np.isnan(r), r <= nodata). The existing tests feed it random_data (integers in [-100, 100], no NaN), so the NaN branch of the alpha mask is never hit on any of the four backends.

  2. true_color all-equal input. When the input has zero range, _normalize_data_cpu guards a divide-by-zero with if range_val != 0. That guard's false branch is never tested.

  3. true_color non-default nodata / c / th. All tests call true_color with default parameters only.

  4. evi validation guards. evi raises ValueError for non-numeric c1/c2, soil_factor outside [-1, 1], and gain < 0. None of these error paths have a test.

  5. savi soil_factor out-of-range. savi raises ValueError when soil_factor is outside [-1, 1]. Not tested.

Proposed fix

Add test-only coverage for the above. No source changes. CUDA is available on the sweep host, so the true_color NaN tests run against cupy and dask+cupy as well as numpy and dask+numpy.

Found by /sweep-test-coverage.

Metadata

Metadata

Assignees

No one assigned

    Labels

    sweep-test-coverageFound by /sweep-test-coveragetestsTest coverage and parity

    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