Skip to content

r.watershed: Add comprehensive tests for map reuse functionality - #6992

Open
sumitchintanwar wants to merge 6 commits into
OSGeo:mainfrom
sumitchintanwar:fix/add-test-r-watershed
Open

sumitchintanwar wants to merge 6 commits into
OSGeo:mainfrom
sumitchintanwar:fix/add-test-r-watershed

Conversation

@sumitchintanwar

Copy link
Copy Markdown
Contributor

This PR adds comprehensive tests for the map reuse functionality. As asked in PR #6953.

The reuse functionality reuses the calculated maps instead of recalculating them again, which saves time and a lot of computational power.

The PR adds three classes of tests:

  1. Basic reuse workflow
  2. Input validation
  3. Performance testing (Skipped in CI)

Tests use @unittest.expectedFailure decorator since accumulation_input and drainage_input parameters are not yet implemented. This allows tests to run in CI without failing the build. Once that feature is merged, The @unittest.expectedFailure will be removed in a follow up commit.

Verification: All tests run successfully locally with the implemented changes, passing with 0 errors

Also, Tests for TCI/SPI calculation and basin delineation with reused maps are not included in this PR, as these features require significant algorithm changes and will be addressed in separate follow-up work once the core map reuse functionality is stable.

@github-actions github-actions Bot added raster Related to raster data processing Python Related code is in Python module tests Related to Test Suite labels Jan 28, 2026
Deactivate CI for TestWatershedReuseLarge until parameters
@sumitchintanwar
sumitchintanwar force-pushed the fix/add-test-r-watershed branch from 508330b to 61dd278 Compare January 29, 2026 12:59
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now needs SPDX header

@Valyrian-Code

Copy link
Copy Markdown
Contributor

#6953 is approved but unmerged since April, so accumulation_input and drainage_input are not in main. I ran the file: exit 0, 4 tests, 2 skipped and 2 expected failures, so nothing here checks anything until that lands. And once those two do start passing, expectedFailure turns them into unexpected successes, which exits 1.

New tests go in pytest now too, though that landed in August, after you opened this.

Smaller things
where what
TestWatershedReuseLarge Skipped on the class and again on its only test.
rand(0, 100) No seed. Ran it twice, got different maps.
length_slope Only assertRasterExists, never compared.
docstring Says r_watershed_reuse_test, file is test_r_watershed_reuse.py.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module Python Related code is in Python raster Related to raster data processing tests Related to Test Suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants