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
Improve Scenario.rename()
to address #601
#791
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #791 +/- ##
=======================================
+ Coverage 95.2% 95.3% +0.1%
=======================================
Files 46 46
Lines 4335 4334 -1
=======================================
+ Hits 4130 4134 +4
+ Misses 205 200 -5
|
@glatterf42 the tests don't pass on python 3.9. Is this related to the way |
550f163
to
44250ff
Compare
44250ff
to
8b4376e
Compare
There are many different error messages which should not be there if some of the tests are passing at all like FAILED message_ix/tests/test_core.py::TestScenario::test_rename[node-Westeros-Tessos-True] - assert 173795.09375 == (173795.09375 * 2) or FAILED message_ix/tests/test_core.py::TestScenario::test_rename[technology-coal_ppl-coal_powerplant-False] - RuntimeError: unhandled Java exception: The index set 'node' does not have an element 'Tessos'! If these things are working for some tests, there should be no reason for them to suddenly fail for others. |
* Rename Tessos to Essos
BTW: another continent in the world of Game of Thrones is called Essos, which is tantalizingly close to the Tessos you used initially, so I took the freedom to rename it if you don't mind :) |
One fail remains, but that is one of our usual flaky suspects for which we haven't yet found the root cause, so I'll just re-run it and rest assured that all your tests are passing as expected :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, thanks :)
Thanks @glatterf42 for reviewing this and the nice suggestion for the name Essos (I somehow mixed that). I see your point. It seems some subsequent tests loaded a scenario that was already manupulated by earlier tests. So, giving explicit scenario names using the "request" feature was very useful. |
One more minor suggestion (I think that's a typo), then we can merge this :) |
Co-authored-by: Fridolin Glatter <83776373+glatterf42@users.noreply.github.com>
@behnam-zakeri @glatterf42 if it's alright, I will jump in here to make the added code a little more concise and probably performant. |
- Use ixmp.util.maybe_{check_out,commit}(). - Use ixmp.Scenario.items(…). - Use pd.{DataFrame,Series}.replace(); only one call per set/parameter. - Handle sets and parameters in the same loop with same operations. - Add logging, type hints. - Expand docstring.
Done, see the first added commit for details. I also expanded the test and documentation. Particularly:
|
Thanks a lot, @khaeru. A learning class for avoiding for loops and if-statements, even when dealing with different item types (i.e., "par" and "set"). |
@glatterf42 given the discussion in the comment thread above, I think this is probably ready to merge provided CI can pass. |
The CI seems fine, the errors are likely flaky, but I'll still confirm this before merging since we don't run the checks again on a merge anymore :) |
This PR improves the utility
Scenario.rename()
to resolve the bug identified in issue #601.How to review
test_core.py
to your message_ixmain
branch. The test should fail with the existing code.PR checklist