Skip to content
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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Shreshth-Malik
Copy link
Contributor

This PR introduces pytest-based tests for the r.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.

@github-actions github-actions bot added raster Related to raster data processing Python Related code is in Python module labels Nov 21, 2024
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")
Copy link
Contributor

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

for line in category_output
}

expected_categories = {1: "", 2: "", 3: ""}
Copy link
Contributor

Choose a reason for hiding this comment

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

why dict with empty keys?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The output for r.category came in the form of {'1': None, '2': None, '3': None}, the categories did not have any labels so i kept the expected categories values empty as well.

Copy link
Contributor

@petrasovaa petrasovaa left a 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

@Shreshth-Malik
Copy link
Contributor Author

@petrasovaa I was trying to test the threshold functionality with cells values 5 and 5.5 and keeping the threshold 0.6. From my understanding if the absolute difference the cell values is <=threshold value then it clumps them together, but in my case it is not doing so. Is my understanding wrong?

My map layout looks something like:
5 5.5 NULL
NULL 5 NULL
NULL 5.5 5.5

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants