def reload_cycle_scenario(request, tmp_path_factory, rc_data_size): """Set up a Platform with *rc_data_size* of random data.""" # Command-line option for the JVM memory limit kwarg = dict() jvm_mem_limit = int(request.config.getoption("--jvm-mem-limit")) if jvm_mem_limit > 0: kwarg["jvmargs"] = f"-Xmx{jvm_mem_limit}M" # Path for this database path = tmp_path_factory.mktemp("reload_cycle") / "base" # Create the Platform. This should be the first in the process, so the # jvmargs are used in :func:`.jdbc.start_jvm`. mp = ixmp.Platform(backend="jdbc", driver="hsqldb", path=path, **kwarg) s0 = ixmp.Scenario(mp, model="foo", scenario="bar 0", version="new") # Add data # currently omitted: time series data with *rc_data_size* elements # s0.add_timeseries(random_ts_data(rc_data_size)) # A set named 'random_set' and parameter 'random_par' with *rc_data_size* # elements add_random_model_data(s0, rc_data_size) s0.commit("") yield s0
def reload_cycle_scenario(request, tmp_path_factory, rc_data_size): """Set up a Platform with *rc_data_size* of random data.""" # Command-line option for the JVM memory limit kwarg = dict() jvm_mem_limit = int(request.config.getoption('--jvm-mem-limit')) if jvm_mem_limit > 0: kwarg['jvmargs'] = f'-Xmx{jvm_mem_limit}M' # Path for this database path = tmp_path_factory.mktemp('reload_cycle') / 'base' # Create the Platform. This should be the first in the process, so the # jvmargs are used in :func:`.jdbc.start_jvm`. mp = ixmp.Platform(backend='jdbc', driver='hsqldb', path=path, **kwarg) s0 = ixmp.Scenario(mp, model='foo', scenario='bar 0', version='new') # Add data # currently omitted: time series data with *rc_data_size* elements # s0.add_timeseries(random_ts_data(rc_data_size)) # A set named 'random_set' and parameter 'random_par' with *rc_data_size* # elements add_random_model_data(s0, rc_data_size) s0.commit('') yield s0
def test_read_excel_big(test_mp, tmp_path): """Excel files with model items split across sheets can be read. https://github.com/iiasa/ixmp/pull/345. """ tmp_path /= 'output.xlsx' # Write a 25-element parameter with max_row=10 → split across 3 sheets scen = ixmp.Scenario(test_mp, **models['dantzig'], version="new") add_random_model_data(scen, 25) scen.to_excel(tmp_path, items=ixmp.ItemType.MODEL, max_row=10) # Initialize target scenario for reading scen_empty = ixmp.Scenario(test_mp, "foo", "bar", version="new") scen_empty.init_set("random_set") scen_empty.init_par("random_par", scen.idx_sets("random_par"), scen.idx_names("random_par")) # File can be read scen_empty.read_excel(tmp_path) assert len(scen_empty.par("random_par")) == 25