Skip to content

t.rast.neighbors: Fix duplicate history, migrate shell test & gunittest to pytest - #7956

Merged
petrasovaa merged 6 commits into
OSGeo:mainfrom
saket0187:t.rast.neighbors-history-once
Oct 21, 2026
Merged

petrasovaa merged 6 commits into
OSGeo:mainfrom
saket0187:t.rast.neighbors-history-once

Conversation

@saket0187

@saket0187 saket0187 commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

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 --overwrite but without -e on an existing output STRDS
recorded the command twice in the dataset history (two identical entries with
the same timestamp):

t.rast.neighbors input=A output=B basename=b
t.rast.neighbors input=A output=B basename=b --overwrite
t.info -h input=B

The history update ran whenever the output existed before the run
(if output_exists:). Without -e, --overwrite deletes and recreates the
dataset, 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 -e changes. I ran every combination of new and
existing output, with and without -e and --overwrite, before and after the
change: exit codes, registered maps, and all other histories are identical.

Shell test migration

test.t.rast.neighbors.sh ran the tool with several methods, sizes, nprocs
values, and with and without -n, but did not check any results. It is
replaced by pytest tests in temporal/t.rast.neighbors/tests/ which use small
deterministic data:

  • test_method: average, maximum, and minimum give the expected value for
    each 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 new
    command

Implemented with the assistance of Claude.
@ninsbl

@github-actions github-actions Bot added temporal Related to temporal data processing Python Related code is in Python module tests Related to Test Suite labels Sep 26, 2026

@ninsbl ninsbl left a comment

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.

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

Comment thread temporal/t.rast.neighbors/tests/conftest.py Outdated
@saket0187
saket0187 requested a review from ninsbl September 29, 2026 11:01
ninsbl
ninsbl previously approved these changes Oct 19, 2026

@petrasovaa petrasovaa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

@saket0187

Copy link
Copy Markdown
Contributor Author

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.

@saket0187 saket0187 changed the title t.rast.neighbors: Fix duplicate history, migrate shell test to pytest t.rast.neighbors: Fix duplicate history, migrate shell test & gunittest to pytest Oct 20, 2026

@petrasovaa petrasovaa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks!

@petrasovaa
petrasovaa merged commit 74f6854 into OSGeo:main Oct 21, 2026
28 checks passed
@github-actions github-actions Bot added this to the 8.6.0 milestone Oct 21, 2026
@saket0187
saket0187 deleted the t.rast.neighbors-history-once branch October 21, 2026 04:37
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 temporal Related to temporal data processing tests Related to Test Suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants