units
units copied to clipboard
Update emissions.py with CO2 equivalent notation
Added CO2-eq notation as this is currently used in our AR6 and other variable templates
I suspect this may not work, because the underlying package, pint
, interprets "-" as a minus sign. But let's see.
Codecov Report
Merging #36 (9245808) into main (00857b7) will not change coverage. The diff coverage is
0.00%
.
:exclamation: Current head 9245808 differs from pull request most recent head 35f975a. Consider uploading reports for the commit 35f975a to get more accurate results
@@ Coverage Diff @@
## main #36 +/- ##
=======================================
Coverage 73.10% 73.10%
=======================================
Files 4 4
Lines 145 145
=======================================
Hits 106 106
Misses 39 39
Impacted Files | Coverage Δ | |
---|---|---|
iam_units/emissions.py | 100.00% <ø> (ø) |
|
iam_units/update.py | 0.00% <0.00%> (ø) |
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 00857b7...35f975a. Read the comment docs.
Note that you edited a file that has as its first line "# DO NOT ALTER THIS FILE MANUALLY!"...
@danielhuppmann good eye! 😅
@byersiiasa you should instead modify the variable _EMI_EQUIV in the file update.py.
Please expand the tests so that the new symbol you've added is tested:
https://github.com/IAMconsortium/units/blob/00857b7e1e1737726ea59e0679ba1c300e2d612e/iam_units/test_all.py#L86-L103
@khaeru sorry not quite intuitive to me here, should I add:
(None, "CO2-eq", "CO2e", 1.0)
or other like (None, "CO2", "CO2-eq", 1.0)
Also - #L92
("AR5GWP100", "CH4", "CO2e", 28),
should not have the e? or should all L89-94 be CO2e?
Here are the relevant pytest docs: https://docs.pytest.org/en/stable/how-to/parametrize.html
To paraphrase, the 4 elements of that tuple get mapped to the function arguments named on L87, i.e. "species_in", "species_out", etc. Then you can see in the function body how those are used to call the tested function. Each line is an individual test case, so e.g.
-
("AR5GWP100", "CH4", "CO2", 28),
tests that this particular conversion works, -
("AR5GWP100", "CH4", "CO2e", 28),
tests that "CO2e" is recognized as equivalent to "CO2" for a target ("species_out"), etc.
You could test "CO2-eq" as species_in and/or species_out, depending on how you expect that it should work!