Exemplo n.º 1
0
def test_configure(test_mp, test_data_path):
    # TODO test: configuration keys 'units', 'replace_units'

    # Configure globally; reads 'rename_dims' section
    configure(rename_dims={'i': 'i_renamed'})

    # Reporting uses the RENAME_DIMS mapping of 'i' to 'i_renamed'
    scen = make_dantzig(test_mp)
    rep = Reporter.from_scenario(scen)
    assert 'd:i_renamed-j' in rep, rep.graph.keys()
    assert ['seattle', 'san-diego'] == rep.get('i_renamed')

    # Original name 'i' are not found in the reporter
    assert 'd:i-j' not in rep, rep.graph.keys()
    pytest.raises(KeyError, rep.get, 'i')

    # Remove the configuration for renaming 'i', so that other tests work
    RENAME_DIMS.pop('i')
Exemplo n.º 2
0
    node_rel="nr",
    node_share="ns",
    time_dest="hd",
    time_origin="ho",
    year_act="ya",
    year_vtg="yv",
    year_rel="yr",
    # Created by reporting
    technology_addon="ta",
    technology_primary="tp",
)

# Configure genno for message_ix.
configure(
    # Units appearing in MESSAGEix test data
    units={"define": "y = year"},
    # Short names for dimensions
    rename_dims=DIMS.copy(),
)

#: Automatic quantities that are the :meth:`~computations.product` of two others.
PRODUCTS = (
    # Each entry is ('output key', ('quantities', 'to', 'multiply')). Full keys are
    # inferred automatically, by add_product().
    ("out", ("output", "ACT")),
    ("in", ("input", "ACT")),
    ("rel", ("relation_activity", "ACT")),
    ("emi", ("emission_factor", "ACT")),
    ("inv", ("inv_cost", "CAP_NEW")),
    ("fom", ("fix_cost", "CAP")),
    ("vom", ("var_cost", "ACT")),
    ("land_out", ("land_output", "LAND")),
Exemplo n.º 3
0
configure(
    # Units appearing in MESSAGEix test data
    units={
        'define': 'y = year',
    },
    # Short names for dimensions
    rename_dims={
        # As defined in the documentation
        'commodity': 'c',
        'emission': 'e',
        'grade': 'g',
        'land_scenario': 's',
        'land_type': 'u',
        'level': 'l',
        'mode': 'm',
        'node': 'n',
        'rating': 'q',
        'relation': 'r',
        'technology': 't',
        'time': 'h',
        'year': 'y',

        # Aliases
        'node_dest': 'nd',
        'node_loc': 'nl',
        'node_origin': 'no',
        'node_rel': 'nr',
        'node_share': 'ns',
        'time_dest': 'hd',
        'time_origin': 'ho',
        'year_act': 'ya',
        'year_vtg': 'yv',
        'year_rel': 'yr',

        # Created by reporting
        'technology_addon': 'ta',
        'technology_primary': 'tp',
    })
Exemplo n.º 4
0
configure(
    # Units appearing in MESSAGEix test data
    units={
        "define": "y = year",
    },
    # Short names for dimensions
    rename_dims={
        # As defined in the documentation
        "commodity": "c",
        "emission": "e",
        "grade": "g",
        "land_scenario": "s",
        "land_type": "u",
        "level": "l",
        "mode": "m",
        "node": "n",
        "rating": "q",
        "relation": "r",
        "technology": "t",
        "time": "h",
        "year": "y",
        # Aliases
        "node_dest": "nd",
        "node_loc": "nl",
        "node_origin": "no",
        "node_rel": "nr",
        "node_share": "ns",
        "time_dest": "hd",
        "time_origin": "ho",
        "year_act": "ya",
        "year_vtg": "yv",
        "year_rel": "yr",
        # Created by reporting
        "technology_addon": "ta",
        "technology_primary": "tp",
    },
)