Repository navigation
Conversation
match() failed with a bare AssertionError from _get_global_start_end when extraction gave an empty model result (e.g. the observation is outside the domain or the location is dry). Check for this up front, alongside the timezone check, and raise a ValueError that names the model result and the observation. Fixes DHI#506
Member
|
Thanks for taking the time to look into this. We're handling this issue internally, so I'm closing this PR. |
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.
Fixes #506
As scoped in #506 (comment), this replaces the bare
assertwith a descriptive error rather than changing matching behaviour.When extraction gives an empty model result (the observation is outside the domain, or the location is dry),
match()used to fail inside_get_global_start_endwith:It now raises:
The check is a new
_check_model_results_not_empty, which runs next to_check_timezone_compatibilityin_match_space_timeand follows the same pattern, so the message can name both the model result and the observation. The assert in_get_global_start_endis removed, because that function is now only reached with non-empty indices. Behaviour changes only for inputs that already failed: they now raiseValueErrorinstead ofAssertionError.Test: I added
test_match_raises_clear_error_when_model_result_is_emptynext to the timezone test. It matches aPointObservationagainst an emptyPointModelResultand checks the error names both of them. It fails onmainand passes here. Apart from this new test,tests/test_match.py,tests/test_comparer.pyandtests/test_simple_compare.pygive the same results before and after the change.ruff check,ruff format --checkand mypy onmatching.pypass.