Repository navigation
t.rast.neighbors: Fix duplicate history, migrate shell test & gunittest to pytest - #7956
Conversation
ninsbl
left a comment
There was a problem hiding this comment.
Good to see you are active also after GSoC @saket0187
I like that you replace the shell based smoke-tests with proper result tests. I do not think it is necessary to test all options of r.neighbors also in t.rast.neighbors, but it would be good if you could test the t.rast.neighbors specific parts (like setting semantic labels, e-flag or suffix or the like)...
petrasovaa
left a comment
There was a problem hiding this comment.
Can you please check whether this could be faster? Module-scoped fixture might be better. Also there is already gunittest, so I wonder if there is any unnecessery overlap.
With these changes, the tests run about twice as fast. I also removed the whole gunittest and moved its remaining checks to pytest, so everything it tested is now covered in one way or another. |
Description
This PR fixes a duplicated command in the history of t.rast.neighbors
output and migrates its shell test & gunittest to pytest.
AI summary
Fix
Running with
--overwritebut without-eon an existing output STRDSrecorded the command twice in the dataset history (two identical entries with
the same timestamp):
The history update ran whenever the output existed before the run
(
if output_exists:). Without-e,--overwritedeletes and recreates thedataset, and creating it already records the command, so it was appended a
second time. The condition now matches the branch that reopens the existing
dataset (
output_exists and flags["e"]).Only overwriting without
-echanges. I ran every combination of new andexisting output, with and without
-eand--overwrite, before and after thechange: exit codes, registered maps, and all other histories are identical.
Shell test migration
test.t.rast.neighbors.shran the tool with several methods, sizes,nprocsvalues, and with and without
-n, but did not check any results. It isreplaced by pytest tests in
temporal/t.rast.neighbors/tests/which use smalldeterministic data:
test_method: average, maximum, and minimum give the expected value foreach map, with maps processed in parallel (
nprocs=2)test_null_maps: a result with only null cells is registered with-n,otherwise it is not registered and its raster is removed
test_overwrite_records_command_once: regression test for the fix(fails without it:
assert 2 == 1)test_extend_appends_command: extending keeps the history and adds the newcommand
Implemented with the assistance of Claude.
@ninsbl