-
-
Notifications
You must be signed in to change notification settings - Fork 329
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.biomass: added test file for i.biomass module #4962
base: main
Are you sure you want to change the base?
Conversation
) | ||
cls.del_temp_region() | ||
|
||
def test_biomass_with_zero_inputs(self): |
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.
I don't think this is particularly useful test. Instead, do a regression test to make sure the values stay the same.
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.
Thank you for the suggestion! I have replaced the test with a regression test to ensure the values remain consistent.
def test_biomass_regression(self): | ||
"""Regression test to ensure i.biomass output remains consistent.""" | ||
self._create_reference_raster() | ||
reference_raster = "biomass_reference" | ||
|
||
self.assertModule( | ||
"i.biomass", | ||
fpar=self.input_rasters["fpar"], | ||
lightuse_efficiency=self.input_rasters["lightuse_eff"], | ||
latitude=self.input_rasters["latitude"], | ||
dayofyear=self.input_rasters["dayofyear"], | ||
transmissivity_singleway=self.input_rasters["transmissivity"], | ||
water_availability=self.input_rasters["water"], | ||
output=self.output_raster, | ||
overwrite=True, | ||
) | ||
self.assertRasterExists(self.output_raster) | ||
self.assertRasterExists(reference_raster) | ||
|
||
output_values = array.array(self.output_raster) | ||
reference_values = array.array(reference_raster) | ||
|
||
self.assertTrue( | ||
np.allclose(output_values, reference_values, atol=2.0), | ||
"Biomass raster values should match the reference values", | ||
) |
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.
That's not what I had in mind. You are computing the reference raster with each test run, but the idea is to compute the reference at the moment you are writing the test and then this reference is considered to be correct, the values are fixed in the test. So when somebody later changes the tool, resulting in different results, the test will fail and you will know that there is potentially a newly introduced bug. See for example r.viewshed test. It is often enough to compute univariate statistics with r.univar and then test those statistics, not cell-by-cell comparison.
This PR introduces a suite of tests for the
i.biomass
GRASS GIS module, covering a range of scenarios, including functionality validation, property testing, edge cases, and performance evaluation.Key updates in this PR include:
Test Case Additions:
Basic Functionality:
Advanced Properties:
Edge Cases:
Performance: