Skip to content

Commit f7fd0b6

Browse files
committed
Update tests for #259
- Set units for 'output' param in .ldv.prepare_tech_econ(). - .transport.files.population_suburb_share is required.
1 parent 7e40743 commit f7fd0b6

File tree

6 files changed

+12
-10
lines changed

6 files changed

+12
-10
lines changed

message_ix_models/model/transport/files.py

-1
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,6 @@ def read_structures() -> "sdmx.message.StructureMessage":
559559
key="population suburb share:n-y:exo",
560560
name="Share of MSA population that is suburban",
561561
units="dimensionless",
562-
required=False,
563562
)
564563

565564
speed = add(

message_ix_models/model/transport/ldv.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ def prepare_tech_econ(
299299

300300
# Create base quantity for "output" parameter
301301
nty = tuple("nty")
302-
c.add(k.output[0] * nty, wildcard(1.0, "", nty))
302+
c.add(k.output[0] * nty, wildcard(1.0, "Gv km", nty))
303303
for i, coords in enumerate(["n::ex world", "t::LDV", "y::model"]):
304304
c.add(
305305
k.output[i + 1] * nty,

message_ix_models/tests/model/transport/test_build.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -276,14 +276,14 @@ def test_build_existing(tmp_path, test_context, url, solve=False):
276276
@pytest.mark.parametrize(
277277
"build_kw",
278278
(
279-
dict(regions="R11", years="A", options=dict()),
280-
dict(regions="R11", years="B", options=dict()),
279+
dict(regions="R11", years="A"),
280+
dict(regions="R11", years="B"),
281281
dict(regions="R11", years="B", options=dict(futures_scenario="A---")),
282282
dict(regions="R11", years="B", options=dict(futures_scenario="debug")),
283-
dict(regions="R12", years="B", options=dict()),
283+
dict(regions="R12", years="B"),
284284
dict(regions="R12", years="B", options=dict(navigate_scenario="act+ele+tec")),
285-
dict(regions="R14", years="B", options=dict()),
286-
param(dict(regions="ISR", years="A", options=dict()), marks=MARK[3]),
285+
param(dict(regions="R14", years="B"), marks=MARK[0]),
286+
param(dict(regions="ISR", years="A"), marks=MARK[3]),
287287
),
288288
)
289289
def test_debug(

message_ix_models/tests/model/transport/test_data.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import pytest
33
from iam_units import registry
44

5-
from message_ix_models.model.transport import build, testing
5+
from message_ix_models.model.transport import build, non_ldv, testing
66
from message_ix_models.model.transport.CHN_IND import get_chn_ind_data, get_chn_ind_pop
77
from message_ix_models.model.transport.roadmap import get_roadmap_data
88
from message_ix_models.model.transport.testing import MARK, assert_units, make_mark
@@ -73,7 +73,7 @@ def test_get_non_ldv_data(test_context, regions, years="B"):
7373
c, _ = testing.configure_build(ctx, regions=regions, years=years)
7474

7575
# Code runs
76-
data = c.get("transport nonldv::ixmp")
76+
data = c.get(f"transport{non_ldv.Pi}")
7777

7878
# Data are provided for the these parameters
7979
exp_pars = {

message_ix_models/tests/model/transport/test_ldv.py

+3
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ def test_get_ldv_data(tmp_path, test_context, dummy_LDV, regions, years) -> None
8080
)
8181

8282
# Output data is returned and has the correct units
83+
# for k, df_group in data["output"].groupby("unit"):
84+
# if k == "": # DEBUG Show data with particular units
85+
# print(df_group.to_string())
8386
assert {"Gp km", "Gv km", "Gv * km", "km", "-"} >= set(
8487
data["output"]["unit"].unique()
8588
)

message_ix_models/tests/project/ssp/test_transport.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def test_cli(tmp_path, mix_models_cli, input_xlsx_path) -> None:
152152
copyfile(input_file, path_in)
153153

154154
# Code runs
155-
result = mix_models_cli.invoke(["ssp", "transport", f"{path_in}"])
155+
result = mix_models_cli.invoke(["ssp", "transport", "--method=A", f"{path_in}"])
156156
assert 0 == result.exit_code, result.output
157157

158158
# Output path was determined automatically and exists

0 commit comments

Comments
 (0)