Skip to content

Commit

Permalink
Reflow comments and docstrings in ixmp.core and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
khaeru committed Feb 21, 2021
1 parent f32f9c2 commit 4bececd
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 30 deletions.
35 changes: 17 additions & 18 deletions ixmp/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,24 +343,23 @@ def add_region_synonym(self, region, mapped_to):
def timeslices(self):
"""Return all subannual timeslices defined in this Platform instance.
Timeslices are a way to represent subannual temporal resolution in
timeseries data. A timeslice consists of a **name** (e.g., 'january',
'summer'), a **category** (e.g., 'months', 'seasons'), and a
**duration** given relative to a full year.
The category and duration do not have any functional relevance within
the ixmp framework, but they may be useful for pre- or post-processing.
For example, they can be used to filter all timeslices of a certain
category (e.g., all months) from the :class:`pandas.DataFrame` returned
by this function or to aggregate subannual data to full-year results.
A timeslice is related to the index set 'time'
in a :class:`message_ix.Scenario` to indicate a subannual temporal
dimension. Alas, timeslices and set elements of time have to be
initialized/defined independently.
See :meth:`add_timeslice` to initialize additional timeslices in the
Platform instance.
Timeslices are a way to represent subannual temporal resolution in timeseries
data. A timeslice consists of a **name** (e.g., 'january', 'summer'), a
**category** (e.g., 'months', 'seasons'), and a **duration** given relative to a
full year.
The category and duration do not have any functional relevance within the ixmp
framework, but they may be useful for pre- or post-processing. For example,
they can be used to filter all timeslices of a certain category (e.g., all
months) from the :class:`pandas.DataFrame` returned by this function or to
aggregate subannual data to full-year results.
A timeslice is related to the index set 'time' in a :class:`message_ix.Scenario`
to indicate a subannual temporal dimension. Alas, timeslices and set elements of
time have to be initialized/defined independently.
See :meth:`add_timeslice` to initialize additional timeslices in the Platform
instance.
Returns
-------
Expand Down
8 changes: 4 additions & 4 deletions ixmp/tests/core/test_platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,16 +343,16 @@ def test_weakref():
# Make a local reference to the backend
backend = mp._backend

# Delete the Platform. Note that this only has an effect if there are no
# existing references to it
# Delete the Platform. Note that this only has an effect if there are no existing
# references to it
del mp

# s.platform is a dead weak reference, so it can't be accessed
with pytest.raises(ReferenceError):
s.platform._backend

# There is only one remaining reference to the backend: the *backend* name
# in the local scope
# There is only one remaining reference to the backend: the *backend* name in the
# local scope
assert getrefcount(backend) - 1 == 1

# The backend is garbage-collected at this point
Expand Down
15 changes: 7 additions & 8 deletions ixmp/tests/core/test_timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
from ixmp.core import IAMC_IDX

# Test data.
# NB the columns are in a specific order; model and scenario come last in the
# data returned by ixmp.
# NB the columns are in a specific order; model and scenario come last in the data
# returned by ixmp.
# TODO fix this; model and scenario should come first, matching the IAMC order.
DATA = {
0: pd.DataFrame.from_dict(
Expand Down Expand Up @@ -56,8 +56,8 @@
scenario="scenario name",
)
),
# NB the columns for geodata methods are inconsistent with those for time-
# series data
# NB the columns for geodata methods are inconsistent with those for time-series
# data
"geo": pd.DataFrame.from_dict(
dict(
region="World",
Expand Down Expand Up @@ -132,10 +132,9 @@ def transact(ts, condition=True, commit_message=""):

# Tests of ixmp.TimeSeries.
#
# Since Scenario is a subclass of TimeSeries, all TimeSeries functionality
# should work exactly the same way on Scenario instances. The *ts* fixture is
# parametrized to yield both TimeSeries and Scenario objects, so every test
# is run on each type.
# Since Scenario is a subclass of TimeSeries, all TimeSeries functionality should work
# exactly the same way on Scenario instances. The *ts* fixture is parametrized to yield
# both TimeSeries and Scenario objects, so every test is run on each type.


@pytest.fixture(scope="function", params=[TimeSeries, Scenario])
Expand Down

0 comments on commit 4bececd

Please sign in to comment.