IAMconsortium / pyam

Analysis & visualization of energy & climate scenarios
https://pyam-iamc.readthedocs.io/
Apache License 2.0
226 stars 118 forks source link

Add tests and set correct return type for `time` #642

Closed danielhuppmann closed 2 years ago

danielhuppmann commented 2 years ago

Description of PR

This PR adds several tests for the IamSlice feature. To ensure consistency, the tests are implemented directly as alternatives to the filter() tests.

It also implements the different return-type for the time attribute (pd.Index, all other dimension-attributes are lists).

codecov[bot] commented 2 years ago

Codecov Report

Merging #642 (59b5161) into add-iamslice (8fe4376) will decrease coverage by 0.6%. The diff coverage is 94.7%.

Impacted file tree graph

@@              Coverage Diff               @@
##           add-iamslice    #642     +/-   ##
==============================================
- Coverage          94.4%   93.7%   -0.7%     
==============================================
  Files                57      57             
  Lines              5698    5701      +3     
==============================================
- Hits               5380    5344     -36     
- Misses              318     357     +39     
Impacted Files Coverage Δ
pyam/core.py 93.7% <75.0%> (+0.2%) :arrow_up:
tests/conftest.py 100.0% <100.0%> (ø)
tests/test_filter.py 100.0% <100.0%> (ø)
tests/test_time.py 100.0% <100.0%> (ø)
tests/test_unfccc.py 40.0% <100.0%> (-60.0%) :arrow_down:
pyam/unfccc.py 24.4% <0.0%> (-65.4%) :arrow_down:

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 8fe4376...59b5161. Read the comment docs.

danielhuppmann commented 2 years ago

Implemented the suggested change. I noticed that this changed the "name"-attribute of the returned pd.Index object (from None to time). This actually seems to be preferable behavior, so I also implemented the minimal changes to make IamDataFrame.time behave in the same manner.