grass.script: Add support for named saved regions in RegionManager#7599
Open
lindakarlovska wants to merge 2 commits into
Conversation
Contributor
|
Wouldn't region= work? |
wenzeslaus
requested changes
Jun 25, 2026
5e6a868 to
db56e25
Compare
b65ab88 to
b503764
Compare
Contributor
Author
You are right @petrasovaa, this works normally. I intuitively expected an interface similar to MaskManager (so that there would be a region_name parameter, like mask_name), and then I didn’t see any example for region= in the docstring, so I didn’t realize that it’s already covered by **kwargs. I think we don’t necessarily need to add a region_name parameter to the API then, adding an example to the docstring should be enough. At the same time, I added a save method, which makes it possible to save the contextual region for later use (it’s basically what I originally implemented via region_name, but now I moved it into a method, which I think makes more sense overall). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds a new region_name parameter to RegionManager, enabling users to work with saved regions:
If region_name refers to an existing saved region and no additional g.region parameters are provided, the saved region is used directly without modification.
Example:
If region_name is provided together with additional g.region parameters, the region is saved under that name and persists after the context exits, allowing for reuse in future operations.
Example:
Existing usage without region_name remains the same as it was:
E.g.:
EDIT:
This PR introduces a new save() method that stores the current region under a persistent name, allowing it to be reused after the context exits. It also adds more docstring examples to clarify that saved regions were already supported through the standard g.region region= parameter.