message_ix icon indicating copy to clipboard operation
message_ix copied to clipboard

Add `.models.shift_period()`

Open khaeru opened this issue 1 year ago • 2 comments

This PR adds a function shift_period() that implements, purely in Python, the behaviour of Scenario.clone(…, shift_first_model_year). Because the latter is currently implemented in the Java code underlying ixmp.JDBCBackend, it cannot be extended in parallel with changes to the implementation of MESSAGE in GAMS (or, in the future, other implementations).

  • Partly addresses #254.
  • Also due to limitations of ixmp.JDBCBackend, is it not supported to set values on model data items of type "variable" or "equation" directly. Thus, this PR can't be completed without iiasa/ixmp#552, iiasa/ixmp#400, or similar.
  • cf. also iiasa/ixmp#424. While the behaviour is currently provided as an argument to the clone() command, the new function is distinct.
  • This PR does not directly address, but will make it much easier to address:
    • #542
    • #543
    • #867
  • The operation of shifting the first model period forward in time is lossy, because parameters like historical_activity have fewer dimensions than the corresponding variables (e.g. ACT). For the opposite operation—shifting the first model period backwards in time—essentially the scenario must be solved again to generate the corresponding solution data in e.g. ACT.

More to be added

How to review

To be added

PR checklist

  • [ ] Complete the implementation
    • [ ] Invoke shift_period() from message_ix.Scenario.clone(…) if the corresponding argument is given.
  • [ ] Continuous integration checks all ✅
  • [ ] Add or expand tests; coverage checks both ✅
  • [ ] Add, expand, or update documentation.
  • [ ] Update release notes.

khaeru avatar Aug 12 '24 09:08 khaeru

Codecov Report

:white_check_mark: All modified and coverable lines are covered by tests. :white_check_mark: Project coverage is 96.5%. Comparing base (f97e386) to head (b3c35ad).

Additional details and impacted files
@@           Coverage Diff           @@
##            main    #873     +/-   ##
=======================================
- Coverage   96.5%   96.5%   -0.1%     
=======================================
  Files         60      60             
  Lines       5155    5179     +24     
=======================================
+ Hits        4976    4999     +23     
- Misses       179     180      +1     
Files with missing lines Coverage Δ
message_ix/message.py 100.0% <100.0%> (ø)
message_ix/tests/test_models.py 100.0% <100.0%> (ø)

... and 1 file with indirect coverage changes

codecov[bot] avatar Aug 12 '24 09:08 codecov[bot]

This will address https://github.com/iiasa/ixmp/issues/75.

glatterf42 avatar Nov 05 '25 15:11 glatterf42