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

i.emissivity: added test file for i.emissivity module #5127

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

Conversation

jayneel-shah18
Copy link
Contributor

This PR introduces a comprehensive test suite for the i.emissivity GRASS GIS module. The test suite is designed to validate core functionality, assess statistical correctness, and handle edge cases to ensure robust module behavior.

Key Updates in this PR:


  • Validate raster output generation and behavior under different NDVI conditions.
  • Ensure correct handling of masked regions.
  • Test behavior with different spatial resolutions.
  • Verify response to extreme NDVI values and partial null inputs.

Test Case Additions


Basic Functionality

  • NDVI Range Validity: Ensure correct emissivity values are generated for valid NDVI inputs (test_emissivity_ndvi_range).
  • Masked Regions: Validate handling of irregularly shaped masks (test_complex_mask).

Advanced Properties

  • Spatial Resolution Handling: Check that the module produces consistent results across different region resolutions (test_region_resolution).
  • Null Value Handling: Assess behavior when NDVI contains null values (test_partial_null_values).
  • Extreme NDVI Values: Test module response when NDVI is outside the valid range (test_extreme_ndvi_values).

Performance

  • The test suite execution times:
    • Windows: 2.315s
    • macOS: 1.353s
    • Ubuntu: 1.868s

Future Enhancements


  • Performance benchmarking for large-scale regions.
  • Stress testing with extreme parameter variations.

This test suite enhances the reliability of the i.emissivity module by covering a broad spectrum of cases. Looking forward to feedback and potential refinements!

@github-actions github-actions bot added Python Related code is in Python module imagery tests Related to Test Suite labels Feb 15, 2025
self.temp_rasters.append("diff_raster")

self.assertRasterMinMax("diff_raster", 0, 0.05)
self.runModule("r.mask", flags="r")
Copy link
Contributor

Choose a reason for hiding this comment

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

You need to remove the mask before you test the outputs.

It should be enough to check with assertRasterFitsUnivar, e.g., the mean, min, max and non-null cells.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the feedback! I have removed the mask before testing the outputs and updated the test to use assertRasterFitsUnivar to check the mean, min and max as suggested.

Comment on lines 109 to 126
def test_region_resolution(self):
"""Test the module behaviour with different region resolutions."""
results = {}
for res in [1, 0.1]:
with self.subTest(res=res):
self.runModule("g.region", n=10, s=0, e=10, w=0, res=res)
self.runModule(
"r.mapcalc", expression=f"{self.input_raster} = 0.6", overwrite=True
)
self.assertModule(
"i.emissivity",
input=self.input_raster,
output=self.output_raster,
overwrite=True,
)
results[res] = self.assertRasterMinMax(self.output_raster, 0, 1)

self.assertAlmostEqual(results[1], results[0.1], delta=0.01)
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see much value in this test for i.emissivity specifically

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have replaced the previous test with the new one focused on default emissivity calculation using critical NDVI values. This ensures that if the module is changed in the future, the test will catch it by failing.

overwrite=True,
)
self.assertRasterExists(self.output_raster)
self.assertRasterMinMax(self.output_raster, 0, 1)
Copy link
Contributor

Choose a reason for hiding this comment

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

I would test with assertRasterFitsUnivar

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have updated the test to use assertRasterFitsUnivar for validation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
imagery module Python Related code is in Python tests Related to Test Suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants