Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2871 +/- ##
==========================================
+ Coverage 95.43% 95.49% +0.05%
==========================================
Files 261 261
Lines 15543 15557 +14
==========================================
+ Hits 14834 14856 +22
+ Misses 709 701 -8 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
I am afraid I need some assistance from some more tech-savvy people to get the tests fixed for this seemingly simple extension of the preprocessor |
|
I'll have a look at this later on today @axel-lauer 🍺 |
…p/ESMValCore into extend_anomalies_preprocessor
|
@axel-lauer ruff is failing with rule COM812 - there's gotta be a missing trailing comma somewhere in the new code; alas, you can try committing once, see it fail, then either fix the issue, or commit again to let the formatter fix that for you (not encouraged, but practical 😁 ) |
|
Thanks @valeriupredoi ! I think I solved the ruff issue (I was looking at the wrong file). It looks like the only problem left is the codecov issue telling me that not all changes are covered. I have no idea how to solve this as I used the unit tests for "standardized anomalies" as a template for the newly implemented "relative anomalies". Would you have an idea what to do? |
There are two different code paths in |
|
Thanks @valeriupredoi and @bouweandela for your help. Following your suggestions, I extended the unit test for the newly implemented relative Unfortunately, Codecov is still complaining about an uncovered error message that is triggered in case of inconsistencies in the input data in I am now out of ideas and I would highly appreciate help from our experts. |
|
@axel-lauer codecov complains about two things:
if reps % 1 != 0:
msg = (
"Cannot safely apply preprocessor to this dataset, "
"since the full time period of this dataset is not "
f"a multiple of the period '{period}'"
)
raise ValueError(
msg,
) if you are unsure of what codecov spits out, you can always run the tests locally with eg |
|
Thanks @valeriupredoi! I tried to cover this check with providing an incomplete reference dataset: Unfortunately, no success so far. The preprocessor code in _time.py crashes already earlier, in function |
|
What if you pass in incomplete input data, like so? @pytest.mark.parametrize("period", ["month"])
def test_relative_anomalies_valerr(period):
"""Test ValueError in relative ``anomalies``."""
cube = make_map_data(number_years=2)[:15]
reference = {
"start_year": 1950,
"start_month": 1,
"start_day": 1,
"end_year": 1950,
"end_month": 12,
"end_day": 31,
}
with assert_raises(ValueError):
anomalies(cube, period, reference, relative=True)? |
…p/ESMValCore into extend_anomalies_preprocessor
|
Thank you @bouweandela! Your idea seems to work. Yay! |
Description
This PR extends the existing preprocessor
anomaliesto allow for optionally calculating relative anomalies (in percent).Checklist
It is the responsibility of the author to make sure the pull request is ready to review. The icons indicate whether the item will be subject to the 🛠 Technical or 🧪 Scientific review.