diff --git a/src/aneris/methods.py b/src/aneris/methods.py index a555758..a62a8ec 100644 --- a/src/aneris/methods.py +++ b/src/aneris/methods.py @@ -441,7 +441,7 @@ def default_method_choice( # or under the absolute threshold if (abs(row.dH) > 0.5) & (row.dH_abs < row.dH_abs_thresh): # If dH is large, but dH_abs is small, this suggests - # The data being harmonised is a small ~near zero component + # The data being harmonised is a small ~near zero component # (under 20% of the parent variable) if row.dH < 0: # If dH is negative (model data > historical data) @@ -452,10 +452,10 @@ def default_method_choice( else: # If dH is positive (model data < historical data) # Then we use the offset method, as the ratio method can substantially - # Increase the values and lead to strange pathways, e.g. + # Increase the values and lead to strange pathways, e.g. # When the variable is small in historical data but growing rapidly (e.g. synfuels) return offset_method - + # If dH_abs is large, this suggests that the component being harmonised is not ~near zero # In this context we can just rely on the ratio method throughout elif abs(row.dH) < 0.5: diff --git a/tests/test_harmonize.py b/tests/test_harmonize.py index 5dd1c0f..35b79ed 100644 --- a/tests/test_harmonize.py +++ b/tests/test_harmonize.py @@ -271,16 +271,19 @@ def test_harmonize_linear_interpolation(): @pytest.mark.ipopt def test_harmonize_budget(): df = _df.copy() + df.columns = df.columns.astype(int) hist = _hist.copy() + hist.columns = hist.columns.astype(int) + methods = _methods.copy() h = harmonize.Harmonizer(df, hist) methods["method"] = "budget" - res = h.harmonize(year="2015", overrides=methods["method"]) + res = h.harmonize(year=2015, overrides=methods["method"]) # base year - obs = res["2015"] - exp = _hist["2015"] + obs = res[2015] + exp = hist[2015] npt.assert_array_almost_equal(obs, exp) # carbon budget conserved @@ -295,5 +298,5 @@ def _carbon_budget(emissions): npt.assert_array_almost_equal( _carbon_budget(res), - _carbon_budget(df) - _carbon_budget(hist.loc[:, "2010":"2015"]), + _carbon_budget(df) - _carbon_budget(hist.loc[:, 2010:2015]), )