-
Notifications
You must be signed in to change notification settings - Fork 0
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
profile_sector()
now handles case "c"
#282
base: main
Are you sure you want to change the base?
Conversation
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.
Here I explore a solution to the bug but I leave it incomplete since fixing this bug requires adapting other tests and maybe code so it would take longer than the time budget I have today.
If you decide this is not worth pursuing, then feel free to close.
mutate(scenario = recode(.data$scenario, "1.5c rps" = "IPR 1.5c RPS", "nz 2050" = "WEO NZ 2050")) |> | ||
mutate(scenario = ifelse(is.na(scenario), grouped_by, scenario)) |> | ||
mutate(scenario = recode_scenario(.data$scenario)) |> |
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.
Here I write a custom helper to recode scenario in a more robust way. It may be wrong but the idea may be useful. I'll discuss in the helper itself.
add_avg_matching_certainty("completion") |> | ||
exclude_rows("risk_category") |
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.
Here is the main "bug".
This line removes rows where risk_category
is NA
and therefore drops the rows we would want to output.
recode_scenario <- function(x) { | ||
out <- gsub("^ipr|^weo", "", x, ignore.case = TRUE) | ||
out <- gsub("_", " ", out) | ||
tolower(trimws(out)) | ||
} |
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.
This helper aims to recode the values of scenario
in a more "programatic" way -- trying to avoid using explicit strings and letter-case. The exception here is "ipr" and "weo" -- which we could also eliminate by rewriting the code so that it removes the first word (whatever that is).
If you keep this function do test it because a test suggest we may want something like "ns 2050" but instead we get "ns 2050 2030".
@@ -271,3 +271,37 @@ test_that("outputs `profile_ranking_avg` at company level", { | |||
company <- unnest_company(out) | |||
expect_true(hasName(company, "reduction_targets_avg")) | |||
}) | |||
|
|||
test_that("given a product in 'ipr', when scenarios has also 'weo', then the product-result includes a 'weo*' `scenario` and maps to `NA` in `sector_profile` (#279, tiltIndicator#739)", { |
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.
Here's the test for the specific case associated to this issue. Meeting this expectation breaks other tests so the job is incomplete.
profile_sector()
fails to handle case "c" #279TODO