-
-
Notifications
You must be signed in to change notification settings - Fork 337
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
r.clump: added tests for r.clump module #4733
base: main
Are you sure you want to change the base?
Conversation
raster/r.clump/tests/test_clump.py
Outdated
output_maps = parse_command("g.list", type="raster") | ||
assert "clumped_map" in output_maps, "Output raster map 'clumped_map' should exist" | ||
|
||
category_output = read_command("r.category", map="clumped_map").strip().split("\n") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r.category has json output, you can use parse_command to get the list
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because r.category already has format option, the call is more complicated:
import json
gs.parse_command("r.category", map="clumped_map", output_format="json", parse=(json.loads, {}))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This still needs to be done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also add test for minsize and threshold
@petrasovaa I was trying to test the My map layout looks something like: |
The error here, now that the test is actually picked up, has to do that a grass session wasn't set. Try to look at |
It's more complicated, it uses some normalization, see r.clump documentation. It's computed here. Something like (diff/range)^2 must be greater than threshold^2 |
This PR introduces
pytest
-based tests for ther.clump
module to validate its functionality. The tests cover:Basic Functionality: Verifies that
r.clump
correctly identifies clumped regions in a raster map.Diagonal Connectivity: Tests the
-d
flag for identifying clumps with diagonal connectivity.The tests use temporary regions and custom raster maps.