Skip to content

Commit

Permalink
upkeep: complete deprecation of ald in favour of abcd (#479)
Browse files Browse the repository at this point in the history
  • Loading branch information
jdhoffa authored Mar 14, 2024
1 parent 57ea218 commit 94d302e
Show file tree
Hide file tree
Showing 15 changed files with 6 additions and 532 deletions.
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export(enquo)
export(enquos)
export(expr)
export(join_abcd_scenario)
export(join_ald_scenario)
export(summarize_weighted_percent_change)
export(summarize_weighted_production)
export(sym)
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# r2dii.analysis (development version)

* Completed deprecation of `ald` in favour of `abcd` (#466).

* `target_market_share` now correctly handles input scenarios with a hyphen in their name (#425).

* `target_market_share` now handles `abcd` with rows where `production` is `NA` by filling with `0` (#423).
Expand Down
1 change: 0 additions & 1 deletion R/join_abcd_scenario.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ join_abcd_scenario <- function(data,
scenario,
region_isos = r2dii.data::region_isos,
add_green_technologies = FALSE) {
data <- rename_and_warn_ald_names(data)

check_portfolio_abcd_scenario(data, abcd, scenario)

Expand Down
64 changes: 0 additions & 64 deletions R/join_ald_scenario.R

This file was deleted.

8 changes: 0 additions & 8 deletions R/summarize_weighted_production.R
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ summarize_weighted_production_ <- function(data, ..., use_credit_limit = FALSE,

old_groups <- dplyr::groups(data)

data <- rename_and_warn_ald_names(data)

crucial <- c("production", "sector_abcd", "year", "technology")

if (with_targets) {
Expand Down Expand Up @@ -149,8 +147,6 @@ summarize_unweighted_production <- function(data, ..., with_targets = FALSE) {
summarize_weighted_percent_change <- function(data, ..., use_credit_limit = FALSE) {
stopifnot(is.data.frame(data))

data <- rename_and_warn_ald_names(data)

data %>%
ungroup() %>%
add_loan_weight(use_credit_limit = use_credit_limit) %>%
Expand All @@ -167,8 +163,6 @@ summarize_weighted_percent_change <- function(data, ..., use_credit_limit = FALS
summarize_weighted_emission_factor <- function(data, ..., use_credit_limit = FALSE) {
stopifnot(is.data.frame(data))

data <- rename_and_warn_ald_names(data)

data %>%
ungroup() %>%
add_loan_weight(use_credit_limit = use_credit_limit) %>%
Expand All @@ -182,8 +176,6 @@ summarize_weighted_emission_factor <- function(data, ..., use_credit_limit = FAL

summarize_unweighted_emission_factor <- function(data, ...) {

data <- rename_and_warn_ald_names(data)

data <- data %>%
select(
-all_of(c("id_loan", "loan_size_credit_limit", "loan_size_outstanding"))
Expand Down
16 changes: 1 addition & 15 deletions R/target_market_share.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
#' output the unweighted production values.
#' @param increasing_or_decreasing A data frame like
#' [r2dii.data::increasing_or_decreasing].
#' @param ald `r lifecycle::badge('superseded')` `ald` has been superseded by
#' `abcd`.
#'
#' @return A tibble including the summarized columns `metric`, `production`,
#' `technology_share`, `percentage_of_initial_production_by_scope` and
Expand Down Expand Up @@ -76,8 +74,7 @@ target_market_share <- function(data,
use_credit_limit = FALSE,
by_company = FALSE,
weight_production = TRUE,
increasing_or_decreasing = r2dii.data::increasing_or_decreasing,
ald = deprecated()) {
increasing_or_decreasing = r2dii.data::increasing_or_decreasing) {
stopifnot(
is.data.frame(data),
is.data.frame(abcd),
Expand All @@ -88,17 +85,6 @@ target_market_share <- function(data,
is.logical(weight_production)
)

if (lifecycle::is_present(ald)) {
lifecycle::deprecate_warn(
"0.2.0 (expected July 2022)",
"target_market_share(ald)",
"target_market_share(abcd)"
)
abcd <- ald
}

data <- rename_and_warn_ald_names(data)

abcd <- fill_and_warn_na(abcd, "production")

region_isos <- change_to_lowercase_and_warn(region_isos, "isos")
Expand Down
16 changes: 1 addition & 15 deletions R/target_sda.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
#' @return A tibble including the summarized columns `emission_factor_metric` and
#' `emission_factor_value`. If `by_company = TRUE`, the output will also have
#' the column `name_abcd`.
#' @param ald `r lifecycle::badge('superseded')` `ald` has been superseded by
#' `abcd`.
#'
#' @export
#'
Expand Down Expand Up @@ -65,8 +63,7 @@ target_sda <- function(data,
co2_intensity_scenario,
use_credit_limit = FALSE,
by_company = FALSE,
region_isos = r2dii.data::region_isos,
ald = deprecated()) {
region_isos = r2dii.data::region_isos) {
stopifnot(
is.data.frame(data),
is.data.frame(abcd),
Expand All @@ -75,17 +72,6 @@ target_sda <- function(data,
is.logical(by_company)
)

if (lifecycle::is_present(ald)) {
lifecycle::deprecate_warn(
"0.2.0 (expected July 2022)",
"target_market_share(ald)",
"target_market_share(abcd)"
)
abcd <- ald
}

data <- rename_and_warn_ald_names(data)

data <- ungroup(warn_grouped(data, "Ungrouping input data."))

crucial_portfolio <- c(
Expand Down
52 changes: 0 additions & 52 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -70,58 +70,6 @@ modify_at_ <- function(.x, .at, .f) {
.x
}

rename_and_warn_ald_names <- function(data) {

if (all(c("name_ald", "name_abcd") %in% names(data))) {

rlang::abort(
"too_many_sectors",
message = glue(
"Column `name_ald` is deprecated as of r2dii.match 0.1.0, please use
`name_abcd` instead."
)
)

} else if ("name_ald" %in% names(data)) {

rlang::warn(
"deprecated_name",
message = glue(
"Column `name_ald` is deprecated as of r2dii.match 0.1.0, please use
`name_abcd` instead."
)
)

data <- dplyr::rename(data, name_abcd = "name_ald")
}

if (all(c("sector_ald", "sector_abcd") %in% names(data))) {

rlang::abort(
"too_many_sectors",
message = glue(
"Column `sector_ald` is deprecated as of r2dii.analysis 0.2.0, please use
`sector_abcd` instead."
)
)

} else if ("sector_ald" %in% names(data)) {

rlang::warn(
"deprecated_name",
message = glue(
"Column `sector_ald` is deprecated as of r2dii.analysis 0.2.0, please use
`sector_abcd` instead."
)
)

data <- dplyr::rename(data, sector_abcd = "sector_ald")
}

data

}

change_to_lowercase_and_warn <- function(data, column) {
if(any(data[[column]] != tolower(data[[column]]), na.rm = TRUE)) {
name_dataset <- deparse(substitute(data))
Expand Down
2 changes: 0 additions & 2 deletions inst/WORDLIST
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
ALD
BMU
CDP
CMD
Expand All @@ -16,7 +15,6 @@ Sectoral
WRI
WWF
abcd
ald
decarbonization
dev
dfrac
Expand Down
52 changes: 0 additions & 52 deletions man/join_ald_scenario.Rd

This file was deleted.

6 changes: 1 addition & 5 deletions man/target_market_share.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 1 addition & 5 deletions man/target_sda.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 0 additions & 16 deletions tests/testthat/_snaps/join_ald_scenario.md

This file was deleted.

Loading

0 comments on commit 94d302e

Please sign in to comment.