Skip to content

r.geomorphon: Rewrite with parson and add json test - #7122

Merged
petrasovaa merged 4 commits into
OSGeo:mainfrom
saket0187:rewrite-r.geomorphon-using-parsonlib
May 18, 2026
Merged

petrasovaa merged 4 commits into
OSGeo:mainfrom
saket0187:rewrite-r.geomorphon-using-parsonlib

Conversation

@saket0187

Copy link
Copy Markdown
Contributor

This PR addresses #6970

I have tried to write this in a cleaner way covering all edge cases. I have also added one test with nested loops to check each key-value pair (with floating-point handling). However, if it looks like too much, we can just use assertEqual. I have removed a few keys like timestamp and generator from expected output as they might cause problems.

Let me know if any changes are needed from my side or if tests need to be modified (or if expected values need to be simplified).

@github-actions github-actions Bot added raster Related to raster data processing Python Related code is in Python C Related code is in C module tests Related to Test Suite CMake labels Feb 28, 2026
Comment thread raster/r.geomorphon/profile.c Resolved
@saket0187
saket0187 requested a review from petrasovaa May 14, 2026 07:24
@petrasovaa

Copy link
Copy Markdown
Contributor

When I run the new test without the change, I get:

======================================================================
FAIL: test_json_profile (__main__.TestClipling.test_json_profile)
Test JSON profile output structure and key values
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/akratoc/dev/grass/grass_main/raster/r.geomorphon/testsuite/test_r_geom.py", line 336, in test_json_profile
    self.assertAlmostEqual(
AssertionError: 133.6702117919922 != 133.67 within 4 places (0.00021179199220000555 difference)

----------------------------------------------------------------------
Ran 3 tests in 14.386s

FAILED (failures=1)

So the PR changes the way the floating point values are printed? It's not a big deal, but it would be good to clarify.

@saket0187

Copy link
Copy Markdown
Contributor Author

When I run the new test without the change, I get:

======================================================================
FAIL: test_json_profile (__main__.TestClipling.test_json_profile)
Test JSON profile output structure and key values
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/akratoc/dev/grass/grass_main/raster/r.geomorphon/testsuite/test_r_geom.py", line 336, in test_json_profile
    self.assertAlmostEqual(
AssertionError: 133.6702117919922 != 133.67 within 4 places (0.00021179199220000555 difference)

----------------------------------------------------------------------
Ran 3 tests in 14.386s

FAILED (failures=1)

So the PR changes the way the floating point values are printed? It's not a big deal, but it would be good to clarify.

Yes, The old path went through format_token_common(), which used %.2f for T_MTR, so the number was rounded before it reached JSON.

@petrasovaa petrasovaa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks!

@petrasovaa
petrasovaa enabled auto-merge (squash) May 18, 2026 20:42
@petrasovaa
petrasovaa merged commit df7adb5 into OSGeo:main May 18, 2026
26 of 27 checks passed
@github-actions github-actions Bot added this to the 8.6.0 milestone May 18, 2026
ninsbl pushed a commit to ninsbl/grass that referenced this pull request Jul 7, 2026
The old path went through format_token_common(), which used %.2f for T_MTR, so the number was rounded before it reached JSON
@echoix echoix linked an issue Jul 17, 2026 that may be closed by this pull request
@infrastation

Copy link
Copy Markdown
Contributor

How does the new JSON test for r.geomorphon manage to pass using an expected output that does not define the top-level keys format_version_major, format_version_minor, timestamp and generator? r.geomorphon is supposed to produce all four at the end of the JSON map, and though for testing purposes it is fine — and even advised — to ignore the volatile values of the latter two, the former two values are essential encoding data.

As far as it looks on the diff, the test does not verify the presence of the four keys and does no verify the two values. Could someone verify this? I do not have GRASS rigged up now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C Related code is in C CMake module Python Related code is in Python raster Related to raster data processing tests Related to Test Suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feat] Rewrite r.geomorphon JSON output to use parson library

3 participants