[ ] This PR addresses an already opened issue (for bug fixes / features)
This PR fixes #xyz
[x] Tests for the changes have been added (for bug fixes / features)
[ ] (If applicable) Documentation has been added / updated (for bug fixes / features)
[x] CHANGELOG.rst has been updated (with summary of main changes)
[ ] Link to issue (:issue:number) and pull request (:pull:number) has been added
What kind of change does this PR introduce?
Before this fix: an indicator that outputs "degC" but as a "temperature: difference" would bug. The compute function would return a dataset with proper units and proper "units_metadata" attribute and then the indicator would try to convert the data to the expected units, but doing so it would only give the units to convert_units_to. It would not give the units_metadata attribute.
thus, convert_units_to was taking the compute function output and getting "delta_degC", as expected, but then it was not able to convert to "degC", of course.
This change passes the whole attrs to convert_units_to so it can understand that the expected units are a difference.
Does this PR introduce a breaking change?
No.
We have no current indicator that output "degC" as "difference" (dtr outputs Kelvins), but the problem would emerge in custom indicators or with sdba.measures.bias where units are not explicitly set, so the "expected ones" are inferred from the compute function's output. Before this fix, the units_metadata attribute was dropped at that point, triggering the bug described above.
Pull Request Checklist:
number
) and pull request (:pull:number
) has been addedWhat kind of change does this PR introduce?
Before this fix: an indicator that outputs "degC" but as a "temperature: difference" would bug. The compute function would return a dataset with proper units and proper "units_metadata" attribute and then the indicator would try to convert the data to the expected units, but doing so it would only give the units to
convert_units_to
. It would not give theunits_metadata
attribute.thus,
convert_units_to
was taking the compute function output and getting "delta_degC", as expected, but then it was not able to convert to "degC", of course.This change passes the whole attrs to
convert_units_to
so it can understand that the expected units are a difference.Does this PR introduce a breaking change?
No.
We have no current indicator that output "degC" as "difference" (dtr outputs Kelvins), but the problem would emerge in custom indicators or with
sdba.measures.bias
where units are not explicitly set, so the "expected ones" are inferred from the compute function's output. Before this fix, theunits_metadata
attribute was dropped at that point, triggering the bug described above.Other information: