r.mapcalc: Add tests for math functions and operators#6975
r.mapcalc: Add tests for math functions and operators#6975saurabh12nxf wants to merge 4 commits intoOSGeo:mainfrom
Conversation
petrasovaa
left a comment
There was a problem hiding this comment.
Thanks! Please see my comments.
| expression = f"{self.output} = log(2.718281828)" | ||
| self.assertModule("r.mapcalc", expression=expression, overwrite=True) | ||
| self.assertRasterFitsUnivar( | ||
| self.output, {"mean": 1, "range": 0}, precision=0.01 |
There was a problem hiding this comment.
Why not more precision?
There was a problem hiding this comment.
I was being overly cautious because I used an approximation of e (2.718281828).
now i am thinking to use precision=1e-6 i think this will be more better .
| self.assertRasterExists(self.output) | ||
|
|
||
|
|
||
| class TestLogicalOperators(TestCase): |
There was a problem hiding this comment.
Test the &&& and ||| operators, they are more tricky. Create suitable input rasters for that.
There was a problem hiding this comment.
Read the r.mapcalc documentation, the test as you have it now is not actually testing the special behavior of the &&& and ||| operators.
|
|
||
| def test_null_creation(self): | ||
| """Test null() function""" | ||
| expression = f"{self.output} = null()" |
There was a problem hiding this comment.
Use the one from setup, no need to generate it again
|
Hi @petrasovaa please once verify it, I have made changes if any improvement still need to do tell me I am happy to do it. |
| self.assertRasterExists(self.output) | ||
|
|
||
|
|
||
| class TestLogicalOperators(TestCase): |
There was a problem hiding this comment.
Read the r.mapcalc documentation, the test as you have it now is not actually testing the special behavior of the &&& and ||| operators.
|
Hi @petrasovaa I’ve updated the &&& and ||| tests to explicitly verify the documented NULL-handling semantics (e.g., NULL &&& 0 == 0, NULL ||| 1 == 1), which distinguish them from && and || thanks for guiding me so many times. |
Expands test coverage for r.mapcalc by adding tests for previously untested functionality.
Tests added:
Tests are fast and focused, avoiding duplication with existing tests in the testsuite folder.