Skip to content

Commit

Permalink
Merge pull request #345 from iiasa/read_excel-correction
Browse files Browse the repository at this point in the history
Correct error in io.s_read_excel for items on multiple sheets
  • Loading branch information
khaeru authored Aug 26, 2020
2 parents bf83f14 + b1efdaf commit 5ad2ad9
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 12 deletions.
17 changes: 6 additions & 11 deletions RELEASE_NOTES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,15 @@ Next release
All changes
-----------

- :pull:`345`: Fix a bug in :meth:`.read_excel` when parameter data is spread across multiple sheets.
- :pull:`363`: Expand documentation and revise installation instructions.
- :pull:`362`: Raise Python exceptions from :class:`.JDBCBackend`.
- :pull:`354`: Add :meth:`Scenario.items`, :func:`.utils.diff`, and allow using filters in CLI command ``ixmp export``.
- :pull:`353`: Add meta functionality.

- :meth:`.Platform.add_model_name` using :meth:`.Backend.add_model_name`
- :meth:`.Platform.add_scenario_name` using :meth:`.Backend.add_scenario_name`
- :meth:`.Platform.get_model_names` using :meth:`.Backend.get_model_names`
- :meth:`.Platform.get_scenario_names` using :meth:`.Backend.get_scenario_names`
- :meth:`.Platform.get_meta` using :meth:`.Backend.get_meta`
- :meth:`.Platform.set_meta` using :meth:`.Backend.set_meta`
- :meth:`.Platform.remove_meta` using :meth:`.Backend.remove_meta`
- :meth:`.Scenario.remove_meta` using :meth:`.Backend.remove_meta`
- deprecate :meth:`.Scenario.delete_meta`
- :pull:`353`: Add functionality for storing ‘meta’ (annotations of model names, scenario names, versions, and some combinations thereof).

- Add :meth:`.Backend.add_model_name`, :meth:`~.Backend.add_scenario_name`, :meth:`~.Backend.get_model_names`, :meth:`~.Backend.get_scenario_names`, :meth:`~.Backend.get_meta`, :meth:`~.Backend.set_meta`, :meth:`~.Backend.remove_meta`.
- Allow these to be called from :class:`.Platform` instances.
- Remove :meth:`.Scenario.delete_meta`.

- :pull:`349`: Avoid modifying indexers dictionary in :meth:`.AttrSeries.sel`.
- :pull:`343`: Add region/unit parameters to :meth:`.Platform.export_timeseries_data`.
Expand Down
2 changes: 1 addition & 1 deletion ixmp/backend/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def parse_item_sheets(name):
dfs.append(xf.parse(x))

# Concatenate once and return
return pd.concat(dfs, axis=1)
return pd.concat(dfs, axis=0)

# Add sets in two passes:
# 1. Index sets, required to initialize other sets.
Expand Down
27 changes: 27 additions & 0 deletions ixmp/tests/backend/test_io.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import ixmp
from ixmp.testing import add_random_model_data, models


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

0 comments on commit 5ad2ad9

Please sign in to comment.