Skip to content

Commit

Permalink
Merge pull request #188 from khaeru/report-message-data
Browse files Browse the repository at this point in the history
- Reporter:
  - add exceptions: KeyExistsError, MissingKeyError, ComputationError.
  - full_key(): handle a wider set of inputs.
- reporting.key: move Key here from reporting.utils
  - name, dims, and tag are all now read-only public properties.
  - cache str() and repr() for a small speed gain
  - add methods drop(), append(), add_tag().
  - use new methods in from_str_or_key().
- reporting.attrseries: move AttrSeries here from reporting.utils
  - add methods dims(), transpose(), to_dataframe()
  - sel(): avoid dropping indices in certain cases.
- reporting.utils: use upper-case consistently for global RENAME_DIMS, UNITS
- computations.write_report: handle str path argument.
- Expand documentation.
  • Loading branch information
khaeru authored Oct 3, 2019
2 parents 5066096 + 8e0c2ff commit dbaac86
Show file tree
Hide file tree
Showing 14 changed files with 654 additions and 318 deletions.
15 changes: 6 additions & 9 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,13 @@
# Apple file system
.DS_Store

# local version of auto-documentation features
/doc/build/**
/doc/source/model/**
# sphinx
doc/build

# files generated during install
# setuptools
build
dist

# credentials
config/*.properties

# testdb
.cache/**
tests/testdb/test.properties
Expand All @@ -55,11 +51,12 @@ rixmp/source/.Rhistory
# virtualenv
.env

# pytest
# pytest and related
*.pid
.coverage*
.coverage
.pytest_cache/
coverage.xml
htmlcov/

# idea
.idea/
Expand Down
1 change: 1 addition & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

# Next Release

- [#188](https://github.com/iiasa/ixmp/pull/188): Enhance reporting.
- [#177](https://github.com/iiasa/ixmp/pull/177): add ability to pass `gams_args` through `Scenario.solve()`
- [#175](https://github.com/iiasa/ixmp/pull/175): Drop support for Python 2.
- [#174](https://github.com/iiasa/ixmp/pull/174): Set `convertStrings=True` for JPype >= 0.7; see the [JPype changelog](https://jpype.readthedocs.io/en/latest/CHANGELOG.html).
Expand Down
4 changes: 2 additions & 2 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,8 @@ def setup(app):

# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {
'python': ('https://docs.python.org/', None),
'dask': ('http://docs.dask.org/en/stable/', None),
'python': ('https://docs.python.org/3/', None),
'dask': ('https://docs.dask.org/en/stable/', None),
'jpype': ('https://jpype.readthedocs.io/en/latest', None),
'pandas': ('https://pandas.pydata.org/pandas-docs/stable/', None),
'pint': ('https://pint.readthedocs.io/en/stable/', None),
Expand Down
75 changes: 47 additions & 28 deletions doc/source/reporting.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,20 @@ Reporting
Python 3. The API and functionality may change without advance notice or a
deprecation period in subsequent releases.

Top-level methods and classes:

.. autosummary::

configure
Reporter
Key

Others:

.. contents::
:local:
:depth: 3

.. automethod:: ixmp.reporting.configure

.. autoclass:: ixmp.reporting.Reporter
Expand Down Expand Up @@ -83,12 +97,43 @@ Reporting
computations.


.. autoclass:: ixmp.reporting.Key
:members:

Quantities in a :class:`Scenario` can be indexed by one or more dimensions.
For example, a parameter with three dimensions can be initialized with:

>>> scenario.init_par('foo', ['a', 'b', 'c'], ['apple', 'bird', 'car'])

Computations for this scenario might use the quantity ``foo`` in different
ways:

1. in its full resolution, i.e. indexed by a, b, and c;
2. aggregated (e.g. summed) over any one dimension, e.g. aggregated over c
and thus indexed by a and b;
3. aggregated over any two dimensions; etc.

A Key for (1) will hash, display, and evaluate as equal to ``'foo:a-b-c'``.
A Key for (2) corresponds to ``'foo:a-b'``, and so forth.

Keys may be generated concisely by defining a convenience method:

>>> def foo(dims):
>>> return Key('foo', dims.split(''))
>>> foo('a b')
foo:a-b


Computations
------------

.. automodule:: ixmp.reporting.computations
:members:

Unless otherwise specified, these methods accept and return
:class:`Quantity <ixmp.reporting.utils.Quantity>` objects for data
arguments/return values.

Calculations:

.. autosummary::
Expand All @@ -113,34 +158,8 @@ Computations
Utilities
---------

.. autoclass:: ixmp.reporting.utils.Key
:members:

Quantities in a :class:`Scenario` can be indexed by one or more dimensions.
For example, a parameter with three dimensions can be initialized with:

>>> scenario.init_par('foo', ['a', 'b', 'c'], ['apple', 'bird', 'car'])

Computations for this scenario might use the quantity ``foo`` in different
ways:

1. in its full resolution, i.e. indexed by a, b, and c;
2. aggregated (e.g. summed) over any one dimension, e.g. aggregated over c
and thus indexed by a and b;
3. aggregated over any two dimensions; etc.

A Key for (1) will hash, display, and evaluate as equal to ``'foo:a-b-c'``.
A Key for (2) corresponds to ``'foo:a-b'``, and so forth.

Keys may be generated concisely by defining a convenience method:

>>> def foo(dims):
>>> return Key('foo', dims.split(''))
>>> foo('a b')
foo:a-b

.. autoclass:: ixmp.reporting.utils.AttrSeries
.. autoclass:: ixmp.reporting.attrseries.AttrSeries

.. automodule:: ixmp.reporting.utils
:members:
:exclude-members: AttrSeries, Key, combo_partition
:exclude-members: AttrSeries
Loading

0 comments on commit dbaac86

Please sign in to comment.