r.fill.stats: migrate tests from gunittest to pytest - #7894
Valyrian-Code wants to merge 3 commits into
Conversation
|
Same CI infra issue as noted on #7780: the failing checks are hitting an HTTP 504 from Launchpad while adding the ubuntugis-unstable PPA, unrelated to this PR. Should clear with a re-run. |
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The NumPy comparison retains a relative tolerance, weakening the previous absolute 1e-6 assertion.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1
Open (1)
What changed in this PR
Migrates r.fill.stats regression coverage from gunittest to pytest, using isolated GRASS sessions, grass.tools, and NumPy comparisons.
Changes:
- Adds parametrized tests for all four interpolation modes.
- Inlines input and reference raster data.
- Removes the legacy gunittest test and data files.
| File | Description |
|---|---|
raster/r.fill.stats/tests/r_fill_stats_test.py |
New pytest-based regression tests and inline fixtures. |
raster/r.fill.stats/testsuite/test_r_fill_stats.py |
Removes the legacy gunittest test. |
raster/r.fill.stats/testsuite/data/input_ascii.txt |
Removes migrated input data. |
raster/r.fill.stats/testsuite/data/output_wmean.txt |
Removes migrated weighted-mean reference. |
raster/r.fill.stats/testsuite/data/output_mean.txt |
Removes migrated mean reference. |
raster/r.fill.stats/testsuite/data/output_median.txt |
Removes migrated median reference. |
raster/r.fill.stats/testsuite/data/output_mode.txt |
Removes migrated mode reference. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
np.allclose applies rtol as well as atol, so with the default rtol=1e-5 a cell near 5 could differ by about 5e-5 and still pass, where the gunittest version used an absolute precision=1e-6. Setting rtol=0 restores that.
|
Good catch, fixed. The original was an absolute |

Migrates the r.fill.stats testsuite from gunittest to pytest, continuing the one-at-a-time migrations from #7635/#7675/#7780/#7893.
Same input and reference outputs as before, now inlined and compared cell by cell with numpy instead of through a difference raster.
Found one discrepancy while doing that: the reference data has the northeast corner cell as null in all four modes, but the tool currently fills it in all four, with a different value per mode (as expected, since each mode computes a different statistic). Every other cell matches the old reference exactly, to float64 precision.
The old test's assertRastersNoDifference could not have caught this: it checks the range of a difference raster, and a difference against a null cell is itself null, so it gets excluded from that range check.
No relevant change to the fill algorithm since this test was added in 2013 explains the corner behavior, so I believe the original reference was wrong for that one cell. This test asserts the corner's current value explicitly rather than reusing the old expectation. Happy to open a separate issue if that seems worthwhile.
Verified locally, all four cases pass.