IAMconsortium / pyam

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

Refactored unit conversion doesn't work within species #368

Closed danielhuppmann closed 4 years ago

danielhuppmann commented 4 years ago

Following the refactoring of the convert_unit() function for GWP (see #361), converting the physical unit of a species (without changing the species) does not work any more unless also providing a GWP-context.

TEST_DF = pd.DataFrame([
    ['model_a', 'scen_a', 'World', 'Primary Energy', 'Mt CO2/yr', 1, 6.],
],
    columns=pyam.IAMC_IDX + [2005, 2010],
)
pyam.IamDataFrame(TEST_DF).convert_unit('Mt CO2/yr', 'Gt CO2/yr')

raises an UndefinedUnitError.

This seems like a bug, because a context is shouldn't be necessary from first principles.

khaeru commented 4 years ago

Good catch. It looks like this wasn't covered by any existing test, so the first step will be to add one. Will open a PR.

danielhuppmann commented 4 years ago

closing as implemented