Skip to content

Commit

Permalink
Use Quantity() instead of reporting.as_quantity() (for iiasa/ixmp#317)
Browse files Browse the repository at this point in the history
  • Loading branch information
khaeru committed Jun 11, 2020
1 parent 42a8a08 commit ddc11ea
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 2 additions & 3 deletions message_ix/reporting/computations.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# Import other comps so they can be imported from this module
from ixmp.reporting import RENAME_DIMS
from ixmp.reporting import RENAME_DIMS, Quantity
from ixmp.reporting.computations import * # noqa: F401, F403
from ixmp.reporting.computations import product
from ixmp.reporting.quantity import as_quantity
import pandas as pd

from .pyam import as_pyam, concat, write_report # noqa: F401
Expand Down Expand Up @@ -46,7 +45,7 @@ def map_as_qty(set_df, full_set):

return set_df.set_index([set_from, set_to])['value'] \
.rename_axis(index=names) \
.pipe(as_quantity)
.pipe(Quantity)


def broadcast_map(quantity, map, rename={}):
Expand Down
4 changes: 2 additions & 2 deletions message_ix/tests/test_reporting.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from logging import WARNING
from pathlib import Path

from ixmp.reporting import Reporter as ixmp_Reporter, as_quantity
from ixmp.reporting import Reporter as ixmp_Reporter, Quantity
from ixmp.testing import assert_qty_equal
from numpy.testing import assert_allclose
import pandas as pd
Expand Down Expand Up @@ -48,7 +48,7 @@ def test_reporter(message_test_mp):

# Quantities contain expected data
dims = dict(coords=['chicago new-york topeka'.split()], dims=['n'])
demand = as_quantity(xr.DataArray([300, 325, 275], **dims), name='demand')
demand = Quantity(xr.DataArray([300, 325, 275], **dims), name='demand')

# NB the call to squeeze() drops the length-1 dimensions c-l-y-h
obs = rep.get('demand:n-c-l-y-h').squeeze(drop=True)
Expand Down

0 comments on commit ddc11ea

Please sign in to comment.