-
Notifications
You must be signed in to change notification settings - Fork 31
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
Use 2023 WEO data in tools.costs
#187
Conversation
Note that the following change was made from the original data file: in the "Nuclear" data sheet, the trailing first columns were deleted (which are hidden in the original data file) so that column A coincides with the start of the data. This is to make the Nuclear sheet consistent with the rest of the notebook.
- Read in 2023 WEO data - Update the rows to be read in - Convert from 2022 USD to 2001 USD (previously 2021 USD to 2001 USD) - Use 2022 values for base year costs
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #187 +/- ##
=====================================
Coverage 76.7% 76.7%
=====================================
Files 112 112
Lines 7154 7154
=====================================
Hits 5491 5491
Misses 1663 1663
|
@measrainsey thanks for the PR and clean-ups! For the moment I imagine no one will want to use the older WEO data. But suppose this:
The question is, how should they do that?
To be clear, I don't think either is necessary for this PR, but it would be good to consider which is desired for the future. @glatterf42 and I can then help implement. |
Hi @khaeru, thanks for your comment and feedback! |
Circling back, would it be possible to review this PR as-is, and possibly work on a longer-term solution for using previous WEO data versions as a separate enhancement/functionality later on? I would like to get this merged sooner for the sake of the SSP update process. Thanks! |
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.
Certainly! As @khaeru mentioned, no need to tackle this issue now, though it would be good to create an issue tracking it.
The PR looks good to me, just one nit-pick: I think F841 errors regard variables that are assigned to but never used; these are easy to fix and don't ever need a # noqa
statement. If you need the variable conversion_factor
, you should be fine without the # noqa
, and if you don't need it, you can use an _
to clarify. After that, happy to approve :)
) | ||
|
||
# Retrieve conversion factor | ||
conversion_factor = registry("1.0 USD_2021").to("USD_2005").magnitude # noqa: F841 | ||
conversion_factor = registry("1.0 USD_2022").to("USD_2005").magnitude # noqa: F841 |
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.
conversion_factor = registry("1.0 USD_2022").to("USD_2005").magnitude # noqa: F841 | |
conversion_factor = registry("1.0 USD_2022").to("USD_2005").magnitude # if variable is needed later on | |
_ = registry("1.0 USD_2022").to("USD_2005").magnitude # if not |
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.
Thanks @glatterf42 ! The conversion_factor
is an interesting case where it is used later on here:
.eval("value = value * @conversion_factor") |
But when the variable is used inside a string, the linting does not pick it up as being used. Without the # noqa: F841
, when I save the file, the linter will automatically delete the conversion_factor
variable line. So that's why the # noqa: F841
is put there. Alternatively, I can change the variable name to _conversion_factor
and use it in the string as @_conversion_factor
, and I think that should work as well. 😄
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.
Huh, I didn't know about such a use-case. However, reading up on it, I found this note: DataFrame.eval()
is only recommended for DataFrames
with more than 1e5 rows. Do you have any estimate about the number of rows in your df
? If it's lower for sure, df.assign()
might be more performant.
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.
I've changed the line to use df.assign()
instead, so now conversion_factor
is explicitly used :)
.assign(value=lambda x: x.value * conversion_factor) |
However, I will note that I believe encounter this same use-case in other places (especially when I use df.query()
).
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.
Thanks! No need to change all occurrences of this now, I just found it odd since I hadn't seen it and so wasn't aware this noqa
might be needed. If you find you prefer assign()
or similar for the other places, feel free to change them later on :)
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 :)
Following our merge recommendations, please merge without rebase or squash :)
Update costs module to move from using the 2022 WEO release to using the 2023 WEO data release
Main changes made:
Additionally, I've changed a few lines in the code to address the comments that were left on #186 which were not properly fixed in that PR.
How to review
For @khaeru and/or @glatterf42 : Read the diff and note that the CI checks all pass.
PR checklist