Skip to content

Commit

Permalink
Update deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasp85 committed Nov 7, 2023
1 parent 1ed7b9a commit da0fd33
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 23 deletions.
3 changes: 1 addition & 2 deletions R/label-currency.R
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,7 @@ dollar <- function(x, accuracy = NULL, scale = 1, prefix = "$",
}

if (lifecycle::is_present(negative_parens)) {
lifecycle::deprecate_warn("1.2.0", "dollar(negative_parens)", "dollar(style_negative)")
style_negative <- if (negative_parens) "parens" else "minus"
lifecycle::deprecate_stop("1.2.0", "dollar(negative_parens)", "dollar(style_negative)")
}

number(
Expand Down
10 changes: 1 addition & 9 deletions R/label-number-si.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,11 @@
#' # If you want the existing behavior, use cut_short_scale()
#' demo_continuous(c(1, 1e9), labels = label_number(scale_cut = cut_short_scale()))
label_number_si <- function(unit = "", accuracy = NULL, scale = 1, suffix = "", ...) {
lifecycle::deprecate_warn(
lifecycle::deprecate_stop(
when = "1.2.0",
what = "label_number_si()",
with = "label_number(scale_cut)"
)

label_number(
suffix = suffix,
scale_cut = cut_bad_si(unit),
accuracy = accuracy,
scale = scale,
...
)
}

cut_bad_si <- function(unit) {
Expand Down
4 changes: 2 additions & 2 deletions R/label-number.R
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ label_comma <- function(accuracy = NULL, scale = 1, prefix = "",
suffix = "", big.mark = ",", decimal.mark = ".",
trim = TRUE, digits, ...) {
if (!missing(digits)) {
lifecycle::deprecate_warn(
lifecycle::deprecate_stop(
when = "1.0.0",
what = "label_comma(digits)",
with = "label_comma(accuracy)"
Expand Down Expand Up @@ -184,7 +184,7 @@ comma <- function(x, accuracy = NULL, scale = 1, prefix = "",
suffix = "", big.mark = ",", decimal.mark = ".",
trim = TRUE, digits, ...) {
if (!missing(digits)) {
lifecycle::deprecate_warn(
lifecycle::deprecate_stop(
when = "1.0.0",
what = "comma(digits)",
with = "comma(accuracy)"
Expand Down
3 changes: 1 addition & 2 deletions R/pal-gradient.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@
#' @param space colour space in which to calculate gradient. Must be "Lab" -
#' other values are deprecated.
#' @export

pal_gradient_n <- function(colours, values = NULL, space = "Lab") {
if (!identical(space, "Lab")) {
lifecycle::deprecate_warn("0.3.0", "pal_gradient_n(space = 'only supports be \"Lab\"')")
lifecycle::deprecate_stop("0.3.0", "pal_gradient_n(space = 'only supports be \"Lab\"')")
}
ramp <- colour_ramp(colours)
force(values)
Expand Down
5 changes: 1 addition & 4 deletions tests/testthat/test-label-currency.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ test_that("negative comes before prefix", {
})

test_that("negative_parens is deprecated", {
lifecycle::expect_deprecated({
out <- label_dollar(negative_parens = TRUE)(-1)
})
expect_equal(out, "($1)")
lifecycle::expect_defunct(label_dollar(negative_parens = TRUE)(1))
})

test_that("preserves NAs", {
Expand Down
6 changes: 2 additions & 4 deletions tests/testthat/test-label-number-si.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
test_that("label_number_si() is deprecated", {
lifecycle::expect_deprecated(lab <- label_number_si(""))
expect_equal(lab(c(0, 1e3, 1e6)), c("0", "1K", "1M"))
lifecycle::expect_defunct(label_number_si(""))

lifecycle::expect_deprecated(lab <- label_number_si("m"))
expect_equal(lab(c(0, 1e3, 1e6)), c("0 m", "1 Km", "1 Mm"))
lifecycle::expect_defunct(label_number_si("m"))
})

0 comments on commit da0fd33

Please sign in to comment.