-
-
Notifications
You must be signed in to change notification settings - Fork 368
t.rast.extract: Handle fully qualified map names and semantic labels #6300
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?
Conversation
for k, v in expected_info.items(): | ||
assert ( | ||
strds_info[k] == v | ||
), f"Expected value for key '{k}' is {v}. Got: {strds_info[k]}" |
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.
Was the default behavior of pytest not enough for dictionaries when developing your tests?
(Like for a bad value, missing, and extra keys)
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.
I wanted to check only a subset of the metadata keys. And unfortunately, it did not print out the key when I compared values are as expected. Are you aware of any build-in methods in pytest that would allow to test if a dictionary is covered by another (regardless of the order of keys and the like...)? I would be happy to adjust and drop the loop...
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.
I didn't check this 100%, but generally it looks good.
python/grass/temporal/extract.py
Outdated
# Make sure STRDS is in the expression referenced with fully qualified name | ||
if sp.base.get_map_id() not in expression: | ||
expression = expression.replace(sp.base.get_name(), sp.base.get_map_id()) |
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.
You could confuse this by including one full name (id) and one name only like "abc@test1 + abc". I'm not sure how much it makes sense with how the inputs are handled. Based on the tests, it seems it does.
Related to that, you can have two "abc" in different mapsets. I don't know how that would be handled here, but maybe that's a separate issue from the one at hand.
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.
Right. Good catch. In 193207a I tried a different method using re.
verbose=True, | ||
overwrite=True, | ||
) | ||
assert gisenv["MAPSET"] == "perc" |
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.
I lack explanation why this is tested. It is okay to test pre- and post-conditions. In this case, it looks wrong that this is tested at the end, while the values are acquired at the beginning (and not modified by anything).
verbose=True, | ||
overwrite=True, | ||
) | ||
strds_info = gs.parse_key_val(tools.t_info(input=result, flags="g").text) |
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.
Does the following work for you or not?
strds_info = gs.parse_key_val(tools.t_info(input=result, flags="g").text) | |
strds_info = tools.t_info(input=result, flags="g").keyval |
It will make a mix of strings and numbers instead of strings only.
assert ( | ||
strds_info[k] == v | ||
), f"Expected value for key '{k}' is {v}. Got: {strds_info[k]}" |
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.
[ruff] reported by reviewdog 🐶
assert ( | |
strds_info[k] == v | |
), f"Expected value for key '{k}' is {v}. Got: {strds_info[k]}" | |
assert strds_info[k] == v, ( | |
f"Expected value for key '{k}' is {v}. Got: {strds_info[k]}" | |
) |
assert ( | ||
strds_info[k] == v | ||
), f"Expected value for key '{k}' is {v}. Got: {strds_info[k]}" |
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.
[ruff] reported by reviewdog 🐶
assert ( | |
strds_info[k] == v | |
), f"Expected value for key '{k}' is {v}. Got: {strds_info[k]}" | |
assert strds_info[k] == v, ( | |
f"Expected value for key '{k}' is {v}. Got: {strds_info[k]}" | |
) |
assert ( | ||
strds_info[k] == v | ||
), f"Expected value for key '{k}' is {v}. Got: {strds_info[k]}" |
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.
[ruff] reported by reviewdog 🐶
assert ( | |
strds_info[k] == v | |
), f"Expected value for key '{k}' is {v}. Got: {strds_info[k]}" | |
assert strds_info[k] == v, ( | |
f"Expected value for key '{k}' is {v}. Got: {strds_info[k]}" | |
) |
This PR appends semantic labels to the basename when expression is given for extraction of raster maps and handles fully qualified STRDS names more reliably. It also adds a pytest based testcase.
Fixes #6254