Repository navigation
grass.script: Fix sign and hemisphere handling in float_or_dms - #7932
Merged
Merged
Conversation
A leading minus sign was applied only to the degrees term, so "-26:45:30" evaluated to -25.24 instead of -26.76. A trailing S or W letter was dropped without negating the value. Apply the sign and hemisphere to the whole value. An empty string now raises ValueError instead of IndexError. Fixes OSGeo#7931
Contributor
|
Thank you, could you also update r.import code since the workaround there is not needed anymore? |
Since float_or_dms now natively handles hemisphere letters and signs, remove the manual slicing and negation workaround in r.import. Signed-off-by: bhuvan-somisetty <somisettybhuvan5@gmail.com>
Contributor
Author
|
Done! I've updated |
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.
Description
grass.script.utils.float_or_dms()now applies a leading-and a trailingSorWhemisphere letter to the whole value. An empty string now raisesValueErrorinstead ofIndexError.Motivation and context
Fixes #7931.
Previously
float_or_dms("-26:45:30")returned -25.24 because the minus signonly affected the degrees term, and
"26:45:30S"returned a positive valuebecause the letter was dropped without negating.
r.importstrips the hemisphere letter before calling the function, so itsbehavior is unchanged.
How has this been tested?
python/grass/script/tests/utils_test.py.pytest python/grass/script/tests/utils_test.pypasses, andruff checkandruff format --checkare clean.Screenshots (if appropriate)
Types of changes
functionality to not work as before)
Checklist
pre-defined prefixes
of this project.