Пример #1
0
Файл: data.py Проект: iiasa/ixmp
def populate_test_platform(platform):
    """Populate `platform` with data for testing.

    Many of the tests in :mod:`ixmp.tests.core` depend on this set of data.

    The data consist of:

    - 3 versions of the Dantzig cannery/transport Scenario.

      - Version 2 is the default.
      - All have :obj:`HIST_DF` and :obj:`TS_DF` as time-series data.

    - 1 version of a TimeSeries with model name 'Douglas Adams' and scenario
      name 'Hitchhiker', containing 2 values.
    """
    s1 = make_dantzig(platform, solve=True, quiet=True)

    s2 = s1.clone()
    s2.set_as_default()

    s2.clone()

    s4 = TimeSeries(platform, **models["h2g2"], version="new")
    s4.add_timeseries(
        pd.DataFrame.from_dict(
            dict(
                region="World",
                variable="Testing",
                unit="???",
                year=[2010, 2020],
                value=[23.7, 23.8],
            )))
    s4.commit("")
    s4.set_as_default()
Пример #2
0
def test_default(mp, ts):
    # NB this is required before the is_default method can be used
    # FIXME should return False regardless
    ts.commit('')

    # Temporary TimeSeries is has not been set_as_default
    assert not ts.is_default()

    ts.set_as_default()
    assert ts.is_default()

    # NB TimeSeries cannot be cloned, so create a new one with the same
    #    name
    ts2 = TimeSeries(mp, ts.model, ts.scenario, version='new')
    ts2.commit('')
    ts2.set_as_default()

    assert ts2.is_default()
    # Original TimeSeries is no longer default
    assert not ts.is_default()