Skip to content

Commit

Permalink
Release candidate 0.6.0 (#389)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielhuppmann committed Jun 4, 2020
1 parent ddca07e commit 0c88f2c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 52 deletions.
10 changes: 8 additions & 2 deletions RELEASE_NOTES.md
@@ -1,4 +1,10 @@
# Next Release
# Release v0.6.0

## Highlights

- Add feature to aggregate timeseries at sub-annual time resolution
- Refactored the iam-units utility from a submodule to a dependency
- Clean up documentation and dependencies

## Individual Updates

Expand All @@ -9,7 +15,7 @@
- [#370](https://github.com/IAMconsortium/pyam/pull/370) Allowed filter to work with np.int64 years and np.datetime64 dates.
- [#369](https://github.com/IAMconsortium/pyam/pull/369) `convert_unit()` supports GWP conversion of same GHG species without context, lower-case aliases for species symbols.
- [#361](https://github.com/IAMconsortium/pyam/pull/361) iam-units refactored from a Git submodule to a Python dependency of pyam.
- [#322](https://github.com/IAMconsortium/pyam/pull/322) Add feature to aggregate timeseries at sub-annual time resolution #322
- [#322](https://github.com/IAMconsortium/pyam/pull/322) Add feature to aggregate timeseries at sub-annual time resolution

# Release v0.5.0

Expand Down
13 changes: 3 additions & 10 deletions pyam/core.py
Expand Up @@ -53,7 +53,7 @@
from pyam.timeseries import fill_series
from pyam._aggregate import _aggregate, _aggregate_region, _aggregate_time,\
_group_and_agg
from pyam.units import convert_unit, convert_unit_with_mapping
from pyam.units import convert_unit

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -767,7 +767,7 @@ def rename(self, mapping=None, inplace=False, append=False,
if not inplace:
return ret

def convert_unit(self, current, to=None, factor=None, registry=None,
def convert_unit(self, current, to, factor=None, registry=None,
context=None, inplace=False):
r"""Convert all data having *current* units to new units.
Expand Down Expand Up @@ -798,7 +798,7 @@ def convert_unit(self, current, to=None, factor=None, registry=None,
Parameters
----------
current : str (or mapping, deprecated)
current : str
Current units to be converted.
to : str
New unit (to be converted to) or symbol for target GHG species. If
Expand Down Expand Up @@ -833,18 +833,11 @@ def convert_unit(self, current, to=None, factor=None, registry=None,
pint.DimensionalityError
without *factor*, when *current* and *to* are not compatible units.
"""
# TODO: deprecate using `dict` in next release (>=0.6.0)
# TODO: make `to` required

# Handle user input
# Check that (only) either factor or registry/context is provided
if factor and any([registry, context]):
raise ValueError('use either `factor` or `pint.UnitRegistry`')

if isinstance(current, dict) and to is None and factor is None:
deprecation_warning('Use explicit keyword arguments instead!',
type='Using a dictionary to convert units')
return convert_unit_with_mapping(self, current, inplace)
# new standard method, remove this comment when deprecating above
return convert_unit(self, current, to, factor, registry, context,
inplace)
Expand Down
15 changes: 0 additions & 15 deletions pyam/units.py
Expand Up @@ -132,18 +132,3 @@ def convert_gwp(context, qty, to):
to = iam_units.format_mass(result, species_to, spec=':~')

return result, to


# Deprecated methods

def convert_unit_with_mapping(df, conversion_mapping, inplace=False):
"""Internal implementation of unit conversion by mapping (deprecated)"""
# TODO: deprecate in next release (>=0.6.0)
ret = df.copy() if not inplace else df
for current_unit, (target_unit, factor) in conversion_mapping.items():
factor = pd.to_numeric(factor)
where = ret.data['unit'] == current_unit
ret.data.loc[where, 'value'] *= factor
ret.data.loc[where, 'unit'] = target_unit
if not inplace:
return ret
25 changes: 0 additions & 25 deletions tests/test_units.py
Expand Up @@ -161,28 +161,3 @@ def test_convert_unit_with_custom_factor(test_df):
df = get_units_test_df(test_df)
exp = pd.Series([1., 6., 1., 6., 4., 14.], name='value')
assert_converted_units(df, 'EJ/yr', 'foo', exp, factor=2)


def test_convert_unit_with_mapping():
# TODO: deprecate in next release (>=0.6.0)
df = IamDataFrame(pd.DataFrame([
['model', 'scen', 'SST', 'test_1', 'A', 1, 5],
['model', 'scen', 'SDN', 'test_2', 'unit', 2, 6],
['model', 'scen', 'SST', 'test_3', 'C', 3, 7],
], columns=['model', 'scenario', 'region',
'variable', 'unit', 2005, 2010],
))

unit_conv = {'A': ['B', 5], 'C': ['D', 3]}

obs = df.convert_unit(unit_conv).data.reset_index(drop=True)

exp = IamDataFrame(pd.DataFrame([
['model', 'scen', 'SST', 'test_1', 'B', 5, 25],
['model', 'scen', 'SDN', 'test_2', 'unit', 2, 6],
['model', 'scen', 'SST', 'test_3', 'D', 9, 21],
], columns=['model', 'scenario', 'region',
'variable', 'unit', 2005, 2010],
)).data.reset_index(drop=True)

pd.testing.assert_frame_equal(obs, exp, check_index_type=False)

0 comments on commit 0c88f2c

Please sign in to comment.