Skip to content

Conversation

@byersiiasa
Copy link

Added CO2-eq notation as this is currently used in our AR6 and other variable templates

Added CO2-eq  notation as this is currently used in our AR6 and other variable templates
@khaeru
Copy link
Contributor

khaeru commented Mar 8, 2022

I suspect this may not work, because the underlying package, pint, interprets "-" as a minus sign. But let's see.

@codecov-commenter
Copy link

codecov-commenter commented Mar 8, 2022

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 73.10%. Comparing base (00857b7) to head (7fe1feb).
⚠️ Report is 42 commits behind head on main.

Files with missing lines Patch % Lines
iam_units/update.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main      #36   +/-   ##
=======================================
  Coverage   73.10%   73.10%           
=======================================
  Files           4        4           
  Lines         145      145           
=======================================
  Hits          106      106           
  Misses         39       39           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@danielhuppmann
Copy link
Member

Note that you edited a file that has as its first line "# DO NOT ALTER THIS FILE MANUALLY!"...

Copy link
Contributor

@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.

Please expand the tests so that the new symbol you've added is tested:

@pytest.mark.parametrize(
"metric, species_in, species_out, expected_value",
[
("AR6GWP100", "CH4", "CO2", 27.9),
("AR5CCFGWP100", "CH4", "CO2", 34),
("AR5GWP100", "CH4", "CO2", 28),
("AR5GWP100", "CH4", "CO2e", 28),
("AR4GWP100", "CH4", "CO2", 25),
("SARGWP100", "CH4", "CO2", 21),
# Same-species conversion with metric=None and compatible names
(None, "CO2", "CO2_eq", 1.0),
(None, "CO2eq", "CO2e", 1.0),
# Species names which are substrings of one another match correctly
("AR5GWP100", "HFC143", "CO2", 328.0),
("AR5GWP100", "HFC143a", "CO2", 4800.0),
],
)
def test_convert_gwp(units, metric, species_in, species_out, expected_value):

@khaeru
Copy link
Contributor

khaeru commented Mar 8, 2022

@danielhuppmann good eye! 😅

@byersiiasa you should instead modify the variable _EMI_EQUIV in the file update.py.

@byersiiasa
Copy link
Author

Please expand the tests so that the new symbol you've added is tested:

@pytest.mark.parametrize(
"metric, species_in, species_out, expected_value",
[
("AR6GWP100", "CH4", "CO2", 27.9),
("AR5CCFGWP100", "CH4", "CO2", 34),
("AR5GWP100", "CH4", "CO2", 28),
("AR5GWP100", "CH4", "CO2e", 28),
("AR4GWP100", "CH4", "CO2", 25),
("SARGWP100", "CH4", "CO2", 21),
# Same-species conversion with metric=None and compatible names
(None, "CO2", "CO2_eq", 1.0),
(None, "CO2eq", "CO2e", 1.0),
# Species names which are substrings of one another match correctly
("AR5GWP100", "HFC143", "CO2", 328.0),
("AR5GWP100", "HFC143a", "CO2", 4800.0),
],
)
def test_convert_gwp(units, metric, species_in, species_out, expected_value):

@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?

@khaeru
Copy link
Contributor

khaeru commented Mar 8, 2022

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!

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.

4 participants