-
-
Notifications
You must be signed in to change notification settings - Fork 396
grass.mapcalc: Fix mapcalc wrapper random seeding #6717
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
base: main
Are you sure you want to change the base?
grass.mapcalc: Fix mapcalc wrapper random seeding #6717
Conversation
|
I think this is a good solution, but I agree with @baharmon in the original issue that the expectation might be to autoseed by default. So perhaps adding the -s flag by default would be good. I would like to deprecate Also please check our CONTRIBUTING.md, specifically our programming guidelines for pre-commit to avoid any formatting issues. The pytests don't run, see if you can fix that. Thanks! |
|
We eventually need to autoseed in r.mapcalc itself. That's the new approach we are taking elsewhere. |
|
So, for the current wrapper implementation, should the Python wrapper automatically add the -s flag (auto-seeding) when no explicit seed is provided, or should users be required to pass flags="s" manually when using rand()? |
|
How about implementing this in a single PR:
I hope this makes sense now. This change would happen on main, we would not backport it to 8.4 because of the changes in r.mapcalc, so technically to fix this in current stable branch we need a separate solution that touches only the mapcalc wrapper, but that would be a different PR. |
|
The most recent push includes the following updates: Once auto-seeding is implemented directly in r.mapcalc, this will become the permanent solution and remove the need for any wrapper-level handling. For the current PR, could you please review the latest changes and let me know if any further revisions are needed? Thanks! |
|
@y-sudharshan if you please reread my comment, I was suggesting to add the autoseeding in r.mapcalc code itself: https://github.com/OSGeo/grass/blob/main/raster/r.mapcalc/main.c |
|
I implemented the changes in r.mapcalc in a separate PR #6742 because that turned out be more complex. So then here please include only changes to the wrapper based on my previous comment:
|
|
@y-sudharshan could you check why the tests are failing and try to fix it? The r.mapcalc autoseeding is now merged so the CI is already running with the new r.mapcalc code. Note that you have to check for the seed='auto' for backwards compatibility, it can't be passed to r.mapcalc, that may the source of some issues here. |
|
Hi, please rerun the tests. The test failed due to a network issue when trying to install the R.Lake series extension with g.extension |
Done |
|
Hi, just following up on the PR. |
petrasovaa
left a comment
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.
Thanks for your patience, coming back from holidays...
The test is failing during the cleanup, you just hid that in the try except block. Look at some other pytest fixtures, e.g. r.mask test, they use temporary directories, so cleanup is automatic.
As for the tests, I would simplify those, they should run quickly. You can use grass.script.array if you want to test the values.
|
Hi, could you please re-run the workflow? It should pass on the next run. |
petrasovaa
left a comment
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.
Looks good now! Thank you for your contribution!
Thank you for taking the time to review this PR! I appreciate your feedback and insights . |
This branch adds parameter support to the mapcalc() and mapcalc_start() wrapper functions in GRASS GIS, enabling users to pass CLI flags like [-s] for automatic PRNG seeding when using the rand() function in raster calculations. The implementation modifies the main raster module to accept a [flags=""] parameter in both functions. It forwards it to the underlying command calls with updated docstrings. At the same time, a new comprehensive test suite provides 8 test methods across two test classes that verify both synchronous and asynchronous functionality with seed parameters, flag parameters, and CLI constraint validation. The fix is minimal, backward compatible (default empty string). It solves the original issue where calling the raster calculator with rand() would fail with a "not seeded" error by allowing users to now use automatic seeding via flags, seed parameters, or explicit seed values for flexible PRNG seeding options.