IAMconsortium / pyam

Analysis & visualization of energy & climate scenarios
https://pyam-iamc.readthedocs.io/
Apache License 2.0
221 stars 115 forks source link

Unit-conversion on non-existing data does not raise DimensionalityError #776

Open danielhuppmann opened 10 months ago

danielhuppmann commented 10 months ago

The pint-package (used by the convert_unit() method) raises a dimensionality error if the units cannot be converted.

However, if a user applies the method convert_unit("source_unit", "target_unit") and the IamDataFrame does not have any data with "source_unit" the validation is skipped.

It would be safer to check whether a unit-conversion is valid even if no data exists.