Skip to content
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

Deprecate the renamed functions. #102

Merged
merged 2 commits into from
Sep 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions R/rename.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
#' `r lifecycle::badge('deprecated')`
#'
#' phsmethods 0.2.1 renamed a number of functions
#' to improve code clarity. The old functions will still
#' work but will produce a warning. After a reasonable
#' amount of time they will be removed completely.
#' to improve code clarity. The old functions no longer
#' work and will error. At the next update they will be
#' removed completely.
#'
#' * `postcode()` -> `format_postcode()`
#' * `age_group()` -> `create_age_groups()`
Expand All @@ -21,7 +21,7 @@ NULL
#' @rdname rename
#' @export
postcode <- function(x, format = c("pc7", "pc8")) {
lifecycle::deprecate_warn("0.2.1", "postcode()", "format_postcode()")
lifecycle::deprecate_stop("0.2.1", "postcode()", "format_postcode()")

return(format_postcode(x = x, format = format))
}
Expand All @@ -33,7 +33,7 @@ age_group <- function(x,
to = 90,
by = 5,
as_factor = FALSE) {
lifecycle::deprecate_warn("0.2.1", "age_group()", "create_age_groups()")
lifecycle::deprecate_stop("0.2.1", "age_group()", "create_age_groups()")

return(create_age_groups(
x = x,
Expand All @@ -47,7 +47,7 @@ age_group <- function(x,
#' @rdname rename
#' @export
fin_year <- function(date) {
lifecycle::deprecate_warn("0.2.1", "fin_year()", "extract_fin_year()")
lifecycle::deprecate_stop("0.2.1", "fin_year()", "extract_fin_year()")

return(extract_fin_year(date = date))
}
6 changes: 3 additions & 3 deletions man/rename.Rd

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

200 changes: 93 additions & 107 deletions tests/testthat/_snaps/rename.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,232 +2,218 @@

Code
expect_equal(stringr::str_length(postcode("G26QE", format = "pc7")), 7)
Warning <lifecycle_warning_deprecated>
`postcode()` was deprecated in phsmethods 0.2.1.
Error <lifecycle_error_deprecated>
`postcode()` was deprecated in phsmethods 0.2.1 and is now defunct.
i Please use `format_postcode()` instead.
Code
expect_equal(stringr::str_length(postcode("G26QE", format = "pc8")), 6)
Warning <lifecycle_warning_deprecated>
`postcode()` was deprecated in phsmethods 0.2.1.
Error <lifecycle_error_deprecated>
`postcode()` was deprecated in phsmethods 0.2.1 and is now defunct.
i Please use `format_postcode()` instead.
Code
expect_equal(stringr::str_length(postcode(c("KA89NB", "PA152TY"), format = "pc7")),
c(7, 7))
Warning <lifecycle_warning_deprecated>
`postcode()` was deprecated in phsmethods 0.2.1.
Error <lifecycle_error_deprecated>
`postcode()` was deprecated in phsmethods 0.2.1 and is now defunct.
i Please use `format_postcode()` instead.
Code
expect_equal(stringr::str_length(postcode(c("KA89NB", "PA152TY"), format = "pc8")),
c(7, 8))
Warning <lifecycle_warning_deprecated>
`postcode()` was deprecated in phsmethods 0.2.1.
Error <lifecycle_error_deprecated>
`postcode()` was deprecated in phsmethods 0.2.1 and is now defunct.
i Please use `format_postcode()` instead.
Code
expect_equal(postcode("G36RB"), "G3 6RB")
Warning <lifecycle_warning_deprecated>
`postcode()` was deprecated in phsmethods 0.2.1.
Error <lifecycle_error_deprecated>
`postcode()` was deprecated in phsmethods 0.2.1 and is now defunct.
i Please use `format_postcode()` instead.
Code
expect_equal(postcode("G432XR"), "G43 2XR")
Warning <lifecycle_warning_deprecated>
`postcode()` was deprecated in phsmethods 0.2.1.
Error <lifecycle_error_deprecated>
`postcode()` was deprecated in phsmethods 0.2.1 and is now defunct.
i Please use `format_postcode()` instead.
Code
expect_equal(postcode("DG29BA"), "DG2 9BA")
Warning <lifecycle_warning_deprecated>
`postcode()` was deprecated in phsmethods 0.2.1.
Error <lifecycle_error_deprecated>
`postcode()` was deprecated in phsmethods 0.2.1 and is now defunct.
i Please use `format_postcode()` instead.
Code
expect_equal(postcode("FK101RY"), "FK101RY")
Warning <lifecycle_warning_deprecated>
`postcode()` was deprecated in phsmethods 0.2.1.
Error <lifecycle_error_deprecated>
`postcode()` was deprecated in phsmethods 0.2.1 and is now defunct.
i Please use `format_postcode()` instead.
Code
expect_equal(postcode("E1W3TJ"), "E1W 3TJ")
Warning <lifecycle_warning_deprecated>
`postcode()` was deprecated in phsmethods 0.2.1.
Error <lifecycle_error_deprecated>
`postcode()` was deprecated in phsmethods 0.2.1 and is now defunct.
i Please use `format_postcode()` instead.
Code
expect_equal(postcode("EC1Y8SE"), "EC1Y8SE")
Warning <lifecycle_warning_deprecated>
`postcode()` was deprecated in phsmethods 0.2.1.
Error <lifecycle_error_deprecated>
`postcode()` was deprecated in phsmethods 0.2.1 and is now defunct.
i Please use `format_postcode()` instead.
Code
input_hampden <- c("G429BA", "g429ba", "G42 9BA", "G 4 2 9 B A", "G429b a")
formatted_hampden <- suppressWarnings(postcode(input_hampden))
Error <lifecycle_error_deprecated>
`postcode()` was deprecated in phsmethods 0.2.1 and is now defunct.
i Please use `format_postcode()` instead.
Code
expect_true(length(unique(formatted_hampden)) == 1)
Error <simpleError>
object 'formatted_hampden' not found
Code
expect_equal(unique(formatted_hampden), "G42 9BA")
Error <simpleError>
object 'formatted_hampden' not found
Code
expect_true(is.na(suppressWarnings(postcode("G2?QE"))))
Error <lifecycle_error_deprecated>
`postcode()` was deprecated in phsmethods 0.2.1 and is now defunct.
i Please use `format_postcode()` instead.
Code
expect_warning(postcode(c("G207AL", "G2O07AL")))
Warning <rlang_warning>
1 non-NA input value does not adhere to the standard UK postcode format (with or without spaces) and will be coded as NA.
The standard format is:
* 1 or 2 letters, followed by
* 1 number, followed by
* 1 optional letter or number, followed by
* 1 number, followed by
* 2 letters
Error <lifecycle_error_deprecated>
`postcode()` was deprecated in phsmethods 0.2.1 and is now defunct.
i Please use `format_postcode()` instead.
Code
expect_equal(suppressWarnings(postcode(c("EH7 5QG", NA, "EH11 2NL", "EH5 2HF*"))),
c("EH7 5QG", NA, "EH112NL", NA))
Error <lifecycle_error_deprecated>
`postcode()` was deprecated in phsmethods 0.2.1 and is now defunct.
i Please use `format_postcode()` instead.
Code
input_dens <- c("Dd37Jy", "DD37JY", "D d 337JY")
warnings_dens <- capture_warnings(postcode(input_dens))
Error <lifecycle_error_deprecated>
`postcode()` was deprecated in phsmethods 0.2.1 and is now defunct.
i Please use `format_postcode()` instead.
Code
expect_length(warnings_dens, 2)
Error <simpleError>
object 'warnings_dens' not found
Code
input_pittodrie <- c("ab245qh", NA, "ab245q", "A B245QH")
warnings_pittodrie <- capture_warnings(postcode(input_pittodrie))
Error <lifecycle_error_deprecated>
`postcode()` was deprecated in phsmethods 0.2.1 and is now defunct.
i Please use `format_postcode()` instead.
Code
expect_length(warnings_pittodrie, 3)
Error <simpleError>
object 'warnings_pittodrie' not found
Code
expect_warning(postcode("g2"), "^1")
Warning <lifecycle_warning_deprecated>
`postcode()` was deprecated in phsmethods 0.2.1.
i Please use `format_postcode()` instead.
Warning <rlang_warning>
1 non-NA input value does not adhere to the standard UK postcode format (with or without spaces) and will be coded as NA.
The standard format is:
* 1 or 2 letters, followed by
* 1 number, followed by
* 1 optional letter or number, followed by
* 1 number, followed by
* 2 letters
Error <lifecycle_error_deprecated>
`postcode()` was deprecated in phsmethods 0.2.1 and is now defunct.
i Please use `format_postcode()` instead.
Code
expect_warning(postcode(c("DG98BS", "dg98b")), "^1")
Warning <lifecycle_warning_deprecated>
`postcode()` was deprecated in phsmethods 0.2.1.
i Please use `format_postcode()` instead.
Warning <rlang_warning>
1 non-NA input value does not adhere to the standard UK postcode format (with or without spaces) and will be coded as NA.
The standard format is:
* 1 or 2 letters, followed by
* 1 number, followed by
* 1 optional letter or number, followed by
* 1 number, followed by
* 2 letters
Error <lifecycle_error_deprecated>
`postcode()` was deprecated in phsmethods 0.2.1 and is now defunct.
i Please use `format_postcode()` instead.
Code
expect_warning(postcode(c("KY1 1RZ", "ky1rz", "KY11 R", "KY11R!")), "^3")
Warning <lifecycle_warning_deprecated>
`postcode()` was deprecated in phsmethods 0.2.1.
Error <lifecycle_error_deprecated>
`postcode()` was deprecated in phsmethods 0.2.1 and is now defunct.
i Please use `format_postcode()` instead.
Warning <rlang_warning>
1 value has lower case letters these will be converted to upper case.
Code
expect_warning(postcode(c("ML53RB", NA, "ML5", "???", 53, as.factor("ML53RB"))),
"^4")
Warning <lifecycle_warning_deprecated>
`postcode()` was deprecated in phsmethods 0.2.1.
Error <lifecycle_error_deprecated>
`postcode()` was deprecated in phsmethods 0.2.1 and is now defunct.
i Please use `format_postcode()` instead.

# age_group is deprecated

Code
expect_identical(age_group(c(4, 51, 21, 89), 0, 80, 10, as_factor = FALSE), c(
"0-9", "50-59", "20-29", "80+"))
Warning <lifecycle_warning_deprecated>
`age_group()` was deprecated in phsmethods 0.2.1.
Error <lifecycle_error_deprecated>
`age_group()` was deprecated in phsmethods 0.2.1 and is now defunct.
i Please use `create_age_groups()` instead.
Code
expect_identical(age_group(c(8, 94, 44, 55, 14), 0, 90, 5, as_factor = TRUE),
factor(c("5-9", "90+", "40-44", "55-59", "10-14"), levels = c("0-4", "5-9",
"10-14", "15-19", "20-24", "25-29", "30-34", "35-39", "40-44", "45-49",
"50-54", "55-59", "60-64", "65-69", "70-74", "75-79", "80-84", "85-89", "90+"),
ordered = TRUE))
Warning <lifecycle_warning_deprecated>
`age_group()` was deprecated in phsmethods 0.2.1.
Error <lifecycle_error_deprecated>
`age_group()` was deprecated in phsmethods 0.2.1 and is now defunct.
i Please use `create_age_groups()` instead.
Code
expect_identical(age_group(c(81, 86, 33, 11), 4, 84, 3, as_factor = FALSE), c(
"79-81", "82+", "31-33", "10-12"))
Warning <lifecycle_warning_deprecated>
`age_group()` was deprecated in phsmethods 0.2.1.
Error <lifecycle_error_deprecated>
`age_group()` was deprecated in phsmethods 0.2.1 and is now defunct.
i Please use `create_age_groups()` instead.
Code
expect_identical(age_group(c(0, 99, 1000, 5, 5), 5, 90, 5, as_factor = FALSE),
c(NA, "90+", "90+", "5-9", "5-9"))
Warning <lifecycle_warning_deprecated>
`age_group()` was deprecated in phsmethods 0.2.1.
Error <lifecycle_error_deprecated>
`age_group()` was deprecated in phsmethods 0.2.1 and is now defunct.
i Please use `create_age_groups()` instead.
Code
expect_identical(age_group(10, as_factor = TRUE), factor(c("10-14"), levels = c(
"0-4", "5-9", "10-14", "15-19", "20-24", "25-29", "30-34", "35-39", "40-44",
"45-49", "50-54", "55-59", "60-64", "65-69", "70-74", "75-79", "80-84",
"85-89", "90+"), ordered = TRUE))
Warning <lifecycle_warning_deprecated>
`age_group()` was deprecated in phsmethods 0.2.1.
Error <lifecycle_error_deprecated>
`age_group()` was deprecated in phsmethods 0.2.1 and is now defunct.
i Please use `create_age_groups()` instead.
Code
expect_error(age_group(c("1", "57", "apple", "12"), as_factor = FALSE))
Warning <lifecycle_warning_deprecated>
`age_group()` was deprecated in phsmethods 0.2.1.
i Please use `create_age_groups()` instead.
Code
expect_error(age_group(c("26", "9", "78", "81"), as_factor = FALSE))
Warning <lifecycle_warning_deprecated>
`age_group()` was deprecated in phsmethods 0.2.1.
i Please use `create_age_groups()` instead.

# fin_year is deprecated

Code
expect_equal(fin_year(as.Date("20120331", "%Y%m%d")), "2011/12")
Warning <lifecycle_warning_deprecated>
`fin_year()` was deprecated in phsmethods 0.2.1.
Error <lifecycle_error_deprecated>
`fin_year()` was deprecated in phsmethods 0.2.1 and is now defunct.
i Please use `extract_fin_year()` instead.
Code
expect_equal(fin_year(as.Date("20120401", "%Y%m%d")), "2012/13")
Warning <lifecycle_warning_deprecated>
`fin_year()` was deprecated in phsmethods 0.2.1.
Error <lifecycle_error_deprecated>
`fin_year()` was deprecated in phsmethods 0.2.1 and is now defunct.
i Please use `extract_fin_year()` instead.
Code
expect_equal(fin_year(as.POSIXct("20190104", format = "%Y%m%d")), "2018/19")
Warning <lifecycle_warning_deprecated>
`fin_year()` was deprecated in phsmethods 0.2.1.
Error <lifecycle_error_deprecated>
`fin_year()` was deprecated in phsmethods 0.2.1 and is now defunct.
i Please use `extract_fin_year()` instead.
Code
expect_equal(fin_year(as.Date("17111993", "%d%m%Y")), "1993/94")
Warning <lifecycle_warning_deprecated>
`fin_year()` was deprecated in phsmethods 0.2.1.
Error <lifecycle_error_deprecated>
`fin_year()` was deprecated in phsmethods 0.2.1 and is now defunct.
i Please use `extract_fin_year()` instead.
Code
expect_equal(fin_year(as.Date("19980404", "%Y%m%d")), "1998/99")
Warning <lifecycle_warning_deprecated>
`fin_year()` was deprecated in phsmethods 0.2.1.
Error <lifecycle_error_deprecated>
`fin_year()` was deprecated in phsmethods 0.2.1 and is now defunct.
i Please use `extract_fin_year()` instead.
Code
expect_equal(fin_year(as.Date("21-Jan-2017", "%d-%B-%Y")), "2016/17")
Warning <lifecycle_warning_deprecated>
`fin_year()` was deprecated in phsmethods 0.2.1.
Error <lifecycle_error_deprecated>
`fin_year()` was deprecated in phsmethods 0.2.1 and is now defunct.
i Please use `extract_fin_year()` instead.
Code
expect_equal(fin_year(as.POSIXct("20181401", format = "%Y%d%m")), "2017/18")
Warning <lifecycle_warning_deprecated>
`fin_year()` was deprecated in phsmethods 0.2.1.
Error <lifecycle_error_deprecated>
`fin_year()` was deprecated in phsmethods 0.2.1 and is now defunct.
i Please use `extract_fin_year()` instead.
Code
expect_equal(fin_year(lubridate::dmy(29102019)), "2019/20")
Warning <lifecycle_warning_deprecated>
`fin_year()` was deprecated in phsmethods 0.2.1.
Error <lifecycle_error_deprecated>
`fin_year()` was deprecated in phsmethods 0.2.1 and is now defunct.
i Please use `extract_fin_year()` instead.
Code
expect_error(fin_year("28102019"))
Warning <lifecycle_warning_deprecated>
`fin_year()` was deprecated in phsmethods 0.2.1.
i Please use `extract_fin_year()` instead.
Code
expect_error(fin_year("28-Oct-2019"))
Warning <lifecycle_warning_deprecated>
`fin_year()` was deprecated in phsmethods 0.2.1.
i Please use `extract_fin_year()` instead.
Code
expect_error(fin_year(as.numeric("28102019")))
Warning <lifecycle_warning_deprecated>
`fin_year()` was deprecated in phsmethods 0.2.1.
i Please use `extract_fin_year()` instead.
Code
expect_error(fin_year(as.factor("28-Oct-2019")))
Warning <lifecycle_warning_deprecated>
`fin_year()` was deprecated in phsmethods 0.2.1.
i Please use `extract_fin_year()` instead.
Code
expect_equal(fin_year(c(lubridate::dmy(5012020), NA)), c("2019/20", NA))
Warning <lifecycle_warning_deprecated>
`fin_year()` was deprecated in phsmethods 0.2.1.
Error <lifecycle_error_deprecated>
`fin_year()` was deprecated in phsmethods 0.2.1 and is now defunct.
i Please use `extract_fin_year()` instead.

Loading