Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend API to support dynamic time slices #264

Merged
merged 15 commits into from Mar 19, 2020
Merged

Conversation

zikolach
Copy link
Contributor

@zikolach zikolach commented Feb 4, 2020

Requirements

Changelist:

Actions:

  • Tests added.
  • Documentation added.
  • Release notes updated.
  • Update this PR with ixmp.jar built from ixmp_source master

Related PR https://github.com/iiasa/ixmp_source/pull/264

@zikolach zikolach self-assigned this Feb 5, 2020
ixmp/core.py Outdated Show resolved Hide resolved
ixmp/backend/base.py Outdated Show resolved Hide resolved
ixmp/backend/base.py Outdated Show resolved Hide resolved
@zikolach zikolach changed the title Replace timespans with timesteps Replace timespans with timeslices Feb 5, 2020
@zikolach
Copy link
Contributor Author

zikolach commented Feb 5, 2020

@danielhuppmann updated based on your suggestions. Could you please help updating documentation (see checkbox in PR description)?

@codecov
Copy link

codecov bot commented Feb 5, 2020

Codecov Report

Merging #264 into master will increase coverage by 0.10%.
The diff coverage is 98.72%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #264      +/-   ##
==========================================
+ Coverage   96.96%   97.07%   +0.10%     
==========================================
  Files          38       38              
  Lines        3530     3760     +230     
==========================================
+ Hits         3423     3650     +227     
- Misses        107      110       +3     
Impacted Files Coverage Δ
ixmp/backend/__init__.py 100.00% <ø> (ø)
ixmp/testing.py 93.91% <ø> (ø)
ixmp/tests/test_cli.py 100.00% <ø> (ø)
ixmp/core.py 93.30% <89.18%> (-0.39%) ⬇️
ixmp/tests/core/test_timeseries.py 99.68% <99.66%> (+0.38%) ⬆️
ixmp/backend/base.py 98.55% <100.00%> (+0.04%) ⬆️
ixmp/backend/jdbc.py 94.87% <100.00%> (+0.05%) ⬆️
ixmp/tests/backend/test_base.py 98.27% <100.00%> (+0.06%) ⬆️
ixmp/tests/core/test_platform.py 100.00% <100.00%> (ø)
ixmp/utils.py 95.91% <100.00%> (+0.14%) ⬆️
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9a2f0fe...bff8df0. Read the comment docs.

@zikolach zikolach marked this pull request as ready for review February 5, 2020 20:39
@zikolach zikolach requested a review from khaeru February 6, 2020 09:44
ixmp/core.py Outdated
@@ -286,6 +286,31 @@ def add_region_synonym(self, region, mapped_to):

self._backend.set_node(region, synonym=mapped_to)

def timeslices(self):
"""Return all subannual time slices defined for the IAMC-style
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please follow the numpydoc standard: the short summary should fit on one line.

ixmp/core.py Show resolved Hide resolved
tests/test_timeslices.py Outdated Show resolved Hide resolved
@khaeru
Copy link
Member

khaeru commented Feb 7, 2020

  • Documentation added.

One thing I would like to see described: what is the meaning of time slice ‘categories’? Do they have any functional effect? How can they be defined?

@zikolach
Copy link
Contributor Author

zikolach commented Feb 7, 2020

One thing I would like to see described: what is the meaning of time slice ‘categories’? Do they have any functional effect? How can they be defined?

From my understanding, time attribute of time series defines to which particular time span time series data belong to. For e.g. to distinguish summer/winter indicator values. But I would prefer @danielhuppmann to formulate the description for documentation as I may have not complete understanding of the purpose or intentions.

@khaeru
Copy link
Member

khaeru commented Feb 27, 2020

FYI, #267 incidentally fixed some CI issues that had come up. Rebasing this PR will help the checks pass.

@khaeru
Copy link
Member

khaeru commented Mar 3, 2020

In #269, @danielhuppmann wrote:

We have an unresolvable naming conflict between MESSAGE (where time is the set of subannual time periods) and the IAMC format, where time is used by openscm (and therefore pyam) for continuous-time format.

I think in this case I have totally failed to understand what the data model is supposed to be—and I thought I had been paying attention/working with the code. New users will be even more confused.

This points to the need for a clear description of the various data structure(s) that are supported and the semantics of how they are represented.

@khaeru
Copy link
Member

khaeru commented Mar 10, 2020

@zikolach I just said to @danielhuppmann on Slack that, because of the adjustments throughout the test suite in #270, this will need a rebase. If it's not obvious how to resolve the conflicts, please ask and I can help.

@zikolach
Copy link
Contributor Author

zikolach commented Mar 11, 2020

FYI, #267 incidentally fixed some CI issues that had come up. Rebasing this PR will help the checks pass.

Tests passed on TC so I pushed changes to original branch. Please have a look as it might be some leftovers in test_timeseries.py after merging timeseries-related tests in one file.

zikolach and others added 3 commits March 11, 2020 15:29
- allow to add timesteps to db
- get list of timesteps from db
- update dockstrings
- update release notes
- add support for adding and retrieving of timeseries having time dimension
- add python3-setuptools to test image Dockerfile
- add docstrings related to the `timeslices` feature
- appease stickler, harmonize notation
- be consistent about upper/lower-case  (per review comment by @zikolach)
- implement review comments by @khaeru
- add docstrings on relation of timeslice and message_ix.Scenario 'time'
- exclude JPype1 version 0.7.2 due to crashes
- add tests and rename time to subannual (#277)
- add check for duplicate timeslice addition (with unit test)
- refactor to names similar to `pyam` for consistency
- extend test for subannual timeseries data
- update timeslices API
   - fix error message produced by add_timeslice (+ fixed test)
   - fix check_out method called on TimeSeries object
   - update test to use time (instead of subannual) name (rename will be addressed separately)
- update timeslices API
- rename time to subannual in "public facing API"
- return from java timeseries time attribute as subannual

Co-authored-by: Daniel Huppmann <dh@dergelbesalon.at>
- adjust test to in-memory db with dynamic population
- move tests to ixmp/tests
- add subannual to test fixtures
- add missing sparse
@zikolach
Copy link
Contributor Author

@danielhuppmann do you plan to add more tests or change anything in this branch?

If not I would go ahead and:

  • merge iiasa/ixmp_source#264
  • update jar in this PR and merge PR into master

@danielhuppmann
Copy link
Member

@danielhuppmann do you plan to add more tests or change anything in this branch?

No, I don't see any additional tests necessary (for the new features) - good to go as far as I'm concerned.

@danielhuppmann danielhuppmann self-requested a review March 18, 2020 06:40
Copy link
Member

@danielhuppmann danielhuppmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @zikolach!

@zikolach
Copy link
Contributor Author

@danielhuppmann I am going to merge ixmp and commit fresh jar build from master to this PR

@khaeru
Copy link
Member

khaeru commented Mar 18, 2020

Can we have a complete description of this PR, for future reference?

@zikolach
Copy link
Contributor Author

Can we have a complete description of this PR, for future reference?

Sure, I'll update it

@zikolach zikolach changed the title Replace timespans with timeslices Extend API to support dynamic time slices Mar 18, 2020
Copy link
Member

@khaeru khaeru left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zikolach @danielhuppmann thanks for the efforts here, it's looking good! A number of minor changes; the major one is to please try to follow the style of the existing tests in terms of re-using data. This makes it much easier to focus on what is being tested in each test, rather than having to skim past many lines that redefine the same data.

If I can supply some text, e.g. for a comment that provides a guide to this style, please ask.

ixmp/backend/base.py Outdated Show resolved Hide resolved
ixmp/backend/base.py Outdated Show resolved Hide resolved
ixmp/backend/base.py Outdated Show resolved Hide resolved
ixmp/backend/base.py Outdated Show resolved Hide resolved
ixmp/backend/jdbc.py Show resolved Hide resolved
ixmp/core.py Outdated Show resolved Hide resolved
ixmp/tests/core/test_timeseries.py Outdated Show resolved Hide resolved
ixmp/tests/core/test_timeseries.py Show resolved Hide resolved
ixmp/tests/test_timeslices.py Outdated Show resolved Hide resolved
ixmp/utils.py Show resolved Hide resolved
@zikolach
Copy link
Contributor Author

@khaeru thanks for great (detailed) feedback! I followed your recommendations of updating docstrings and tests.

- move adding subannual column to to_iamc_template
- simplify method implementation
- add missing subannual parameter to remove_timeseries/backend
@zikolach zikolach merged commit e66f3f8 into master Mar 19, 2020
@zikolach zikolach deleted the feature/time-steps branch March 19, 2020 10:06
khaeru added a commit to khaeru/message_ix that referenced this pull request May 8, 2020
khaeru added a commit that referenced this pull request May 25, 2021
In #270, this file was cleaned up and tests were collected in a class,
with parametrization. Shortly after, #264 was merged, which squashed
these improvements. This commit rescues the improvements and adapts
additions since then to the same pattern.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants