Skip to content

Commit

Permalink
Check gradual deprecation #193
Browse files Browse the repository at this point in the history
  • Loading branch information
finnlindgren committed Jun 10, 2023
1 parent 4a2a0cf commit 2760c0d
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 50 deletions.
2 changes: 1 addition & 1 deletion R/environment.R
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,7 @@ bru_log_active <- function(activation = NULL) {
#' }
#'
init.tutorial <- function() {
lifecycle::deprecate_warn(
lifecycle::deprecate_stop(
"2.5.0",
I("init.tutorial()"),
I(
Expand Down
34 changes: 10 additions & 24 deletions R/fmesher_crs.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@
#' @export

fm_has_PROJ6 <- function() {
# TODO: deprecate_warn
lifecycle::deprecate_stop("2.7.1",
lifecycle::deprecate_stop("2.8.0",
"fm_has_PROJ6()",
details = c(
i = "Since inlabru 2.7.1, fm_has_PROJ6() always returns TRUE",
i = "rgdal/PROJ4 is no longer supported."
)
)
Expand All @@ -20,28 +18,17 @@ fm_has_PROJ6 <- function() {
#' features even though PROJ6 is available

fm_not_for_PROJ6 <- function(fun = NULL) {
lifecycle::deprecate_warn("2.7.1",
lifecycle::deprecate_stop("2.8.0",
"fm_not_for_PROJ6()",
details = c(x = "rgdal/PROJ4 is no longer supported.")
)
fun <- fm_caller_name(1, fun)
msg <- paste0(
"Call stack:\n",
paste0(fm_call_stack(end = 1), collapse = "\n")
)
stop(paste0(
"'",
fun,
"()' should not be used with PROJ6 and rgdal v3\n",
msg
))
}

#' @describeIn inlabru-deprecated `fm_not_for_PROJ4` is called to give an error when
#' calling methods that are only available for PROJ6

fm_not_for_PROJ4 <- function(fun = NULL) {
lifecycle::deprecate_stop("2.7.1",
lifecycle::deprecate_stop("2.8.0",
"fm_not_for_PROJ4()",
details = c(x = "rgdal/PROJ4 is no longer supported.")
)
Expand All @@ -51,7 +38,7 @@ fm_not_for_PROJ4 <- function(fun = NULL) {
#' to using old PROJ4 methods when a PROJ6 method hasn't been implemented

fm_fallback_PROJ6 <- function(fun = NULL) {
lifecycle::deprecate_stop("2.7.1",
lifecycle::deprecate_stop("2.8.0",
"fm_not_for_PROJ4()",
details = c(x = "rgdal/PROJ4 requested by PROJ4 is no longer supported.")
)
Expand All @@ -64,11 +51,10 @@ fm_fallback_PROJ6 <- function(fun = NULL) {
#' is required but not available

fm_requires_PROJ6 <- function(fun = NULL) {
lifecycle::deprecate_stop("2.7.1",
lifecycle::deprecate_stop("2.8.0",
"fm_requires_PROJ6()",
details = c(x = "Now always returns TRUE. rgdal/PROJ4 is no longer supported.")
details = c(x = "rgdal/PROJ4 is no longer supported.")
)
TRUE
}


Expand Down Expand Up @@ -100,7 +86,7 @@ fm_as_sp_crs <- function(x, ...) {
#' @export

fm_sp_get_crs <- function(x) {
lifecycle::deprecate_warn("2.7.1", "fm_sp_get_crs()", "fm_CRS()")
lifecycle::deprecate_warn("2.8.0", "fm_sp_get_crs()", "fm_CRS()")
fm_CRS(x)
}

Expand Down Expand Up @@ -1311,7 +1297,7 @@ fm_list_as_CRS <- function(x, ...) {
#' print(fm_proj4string(crs1))
#' print(fm_proj4string(crs2))
fm_CRSargs <- function(x, ...) {
lifecycle::deprecate_warn("2.7.0.9012", "fm_CRSargs()", "fm_proj4string()")
lifecycle::deprecate_warn("2.8.0", "fm_CRSargs()", "fm_proj4string()")

fm_proj4string(x)
}
Expand Down Expand Up @@ -1386,7 +1372,7 @@ fm_proj4string <- function(crs) {

fm_crs_get_wkt <- function(crs) {
lifecycle::deprecate_warn(
"2.7.0.9012",
"2.8.0",
"fm_crs_get_wkt()",
"fm_wkt()"
)
Expand Down Expand Up @@ -1997,7 +1983,7 @@ fm_transform.inla.mesh.segment <- function(x, crs = fm_crs(x), ..., passthrough
#' @seealso [fm_transform()]
#' @export
fm_spTransform <- function(x, ...) {
lifecycle::deprecate_soft("2.7.1", "fm_spTransform()", "fm_transform()")
lifecycle::deprecate_soft("2.8.0", "fm_spTransform()", "fm_transform()")
UseMethod("fm_spTransform")
}

Expand Down
17 changes: 12 additions & 5 deletions R/fmesher_evaluator.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,12 @@ fm_evaluate <- function(...) {
#' @export
#' @rdname fm_evaluate
fm_evaluate.inla.mesh <- function(mesh, field, ...) {
lifecycle::deprecate_stop(
"2.8.0",
"fm_evaluate(field = ' must not be missing or NULL.')",
"fm_evaluator()")
if (missing(field) || is.null(field)) {
lifecycle::deprecate_stop(
"2.8.0",
"fm_evaluate(field = ' must not be missing or NULL.')",
"fm_evaluator()")
}

proj <- fm_evaluator(mesh, ...)
fm_evaluate(proj, field = field)
Expand All @@ -70,7 +72,12 @@ fm_evaluate.inla.mesh <- function(mesh, field, ...) {
#' @export
#' @rdname fm_evaluate
fm_evaluate.inla.mesh.1d <- function(mesh, field, ...) {
stopifnot(!missing(field) && !is.null(field))
if (missing(field) || is.null(field)) {
lifecycle::deprecate_stop(
"2.8.0",
"fm_evaluate(field = ' must not be missing or NULL.')",
"fm_evaluator()")
}

proj <- fm_evaluator(mesh, ...)
fm_evaluate(proj, field)
Expand Down
26 changes: 13 additions & 13 deletions R/mappers.R
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ ibm_values <- function(mapper, inla_f = FALSE, ...) {
#' the allowed type of input format.
#' @export
ibm_amatrix <- function(mapper, input, state = NULL, inla_f = FALSE, ...) {
lifecycle::deprecate_soft(
lifecycle::deprecate_warn(
"2.7.0",
"ibm_amatrix()",
"ibm_jacobian()"
Expand Down Expand Up @@ -749,7 +749,7 @@ ibm_jacobian.bru_mapper_inla_mesh_2d <- function(mapper, input, ...) {
#' @export
#' @describeIn inlabru-deprecated Replaced by [ibm_jacobian()]
ibm_amatrix.bru_mapper_inla_mesh_2d <- function(...) {
lifecycle::deprecate_warn("2.6.0", "ibm_amatrix()", "ibm_jacobian()")
lifecycle::deprecate_stop("2.6.0", "ibm_amatrix()", "ibm_jacobian()")
ibm_jacobian(...)
}

Expand Down Expand Up @@ -807,7 +807,7 @@ ibm_jacobian.bru_mapper_inla_mesh_1d <- function(mapper, input, ...) {
#' @export
#' @describeIn inlabru-deprecated Replaced by [ibm_jacobian()]
ibm_amatrix.bru_mapper_inla_mesh_1d <- function(...) {
lifecycle::deprecate_warn("2.6.0", "ibm_amatrix()", "ibm_jacobian()")
lifecycle::deprecate_stop("2.6.0", "ibm_amatrix()", "ibm_jacobian()")
ibm_jacobian(...)
}

Expand Down Expand Up @@ -850,7 +850,7 @@ ibm_jacobian.bru_mapper_index <- function(mapper, input, state, ...) {
#' @export
#' @describeIn inlabru-deprecated Replaced by [ibm_jacobian()]
ibm_amatrix.bru_mapper_index <- function(...) {
lifecycle::deprecate_warn("2.6.0", "ibm_amatrix()", "ibm_jacobian()")
lifecycle::deprecate_stop("2.6.0", "ibm_amatrix()", "ibm_jacobian()")
ibm_jacobian(...)
}

Expand Down Expand Up @@ -1098,7 +1098,7 @@ ibm_jacobian.bru_mapper_linear <- function(mapper, input, ...) {
#' @export
#' @describeIn inlabru-deprecated Replaced by [ibm_jacobian()]
ibm_amatrix.bru_mapper_linear <- function(...) {
lifecycle::deprecate_warn("2.6.0", "ibm_amatrix()", "ibm_jacobian()")
lifecycle::deprecate_stop("2.6.0", "ibm_amatrix()", "ibm_jacobian()")
ibm_jacobian(...)
}

Expand Down Expand Up @@ -1274,7 +1274,7 @@ ibm_jacobian.bru_mapper_factor <- function(mapper, input, ...) {
#' @export
#' @describeIn inlabru-deprecated Replaced by [ibm_jacobian()]
ibm_amatrix.bru_mapper_factor <- function(...) {
lifecycle::deprecate_warn("2.6.0", "ibm_amatrix()", "ibm_jacobian()")
lifecycle::deprecate_stop("2.6.0", "ibm_amatrix()", "ibm_jacobian()")
ibm_jacobian(...)
}

Expand Down Expand Up @@ -1323,28 +1323,28 @@ ibm_eval.bru_mapper_const <- function(mapper, input, state = NULL, ...) {
#' @export
#' @describeIn inlabru-deprecated Creates a [bru_mapper_const()] mapper.
bru_mapper_offset <- function(...) {
lifecycle::deprecate_soft("2.6.0", "bru_mapper_offset()", "bru_mapper_const()")
lifecycle::deprecate_warn("2.6.0", "bru_mapper_offset()", "bru_mapper_const()")
bru_mapper_define(bru_mapper_const(), new_class = "bru_mapper_offset")
}

#' @export
#' @describeIn inlabru-deprecated Replaced by [bru_mapper_const] methods
ibm_n.bru_mapper_offset <- function(...) {
lifecycle::deprecate_soft("2.6.0", "bru_mapper_offset()", "bru_mapper_const()")
lifecycle::deprecate_warn("2.6.0", "bru_mapper_offset()", "bru_mapper_const()")
NextMethod()
}
#' @export
#' @describeIn inlabru-deprecated Replaced by [bru_mapper_const] methods
ibm_values.bru_mapper_offset <- function(...) {
lifecycle::deprecate_soft("2.6.0", "bru_mapper_offset()", "bru_mapper_const()")
lifecycle::deprecate_warn("2.6.0", "bru_mapper_offset()", "bru_mapper_const()")
NextMethod()
}

#' @export
#' @describeIn inlabru-deprecated Replaced by [bru_mapper_const] methods
ibm_amatrix.bru_mapper_offset <- function(...) {
lifecycle::deprecate_soft("2.6.0", "bru_mapper_offset()", "bru_mapper_const()")
lifecycle::deprecate_warn("2.6.0", "ibm_amatrix()", "ibm_jacobian()")
lifecycle::deprecate_warn("2.6.0", "bru_mapper_offset()", "bru_mapper_const()")
lifecycle::deprecate_stop("2.6.0", "ibm_amatrix()", "ibm_jacobian()")
NextMethod()
}

Expand Down Expand Up @@ -2283,7 +2283,7 @@ ibm_jacobian.bru_mapper_multi <- function(mapper,
#' @export
#' @describeIn inlabru-deprecated Replaced by [ibm_jacobian()]
ibm_amatrix.bru_mapper_multi <- function(...) {
lifecycle::deprecate_warn("2.6.0", "ibm_amatrix()", "ibm_jacobian()")
lifecycle::deprecate_stop("2.6.0", "ibm_amatrix()", "ibm_jacobian()")
ibm_jacobian(...)
}

Expand Down Expand Up @@ -2676,7 +2676,7 @@ ibm_jacobian.bru_mapper_collect <- function(mapper, input, state = NULL,
#' @export
#' @describeIn inlabru-deprecated Replaced by [ibm_jacobian()]
ibm_amatrix.bru_mapper_collect <- function(...) {
lifecycle::deprecate_warn("2.6.0", "ibm_amatrix()", "ibm_jacobian()")
lifecycle::deprecate_stop("2.6.0", "ibm_amatrix()", "ibm_jacobian()")
ibm_jacobian(...)
}

Expand Down
12 changes: 6 additions & 6 deletions R/mesh.R
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,12 @@ vertices.inla.mesh <- function(...) {
#' }
#'
pixels <- function(mesh, nx = 150, ny = 150, mask = TRUE) {
# lifecycle::deprecate_soft(
# "2.8.0",
# "pixels()",
# "fm_pixels(format = 'sp')",
# details = "The fm_pixels() function can generate sf, terra, and sp output."
# )
lifecycle::deprecate_soft(
"2.8.0",
"pixels()",
"fm_pixels(format = 'sp')",
details = "The fm_pixels() function can generate sf, terra, and sp output."
)
fm_pixels(mesh, nx = nx, ny = ny, mask = mask, format = "sp")
}

Expand Down
2 changes: 1 addition & 1 deletion R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ eval_spatial <- function(data, where, layer = NULL, selector = NULL) {

#' @describeIn inlabru-deprecated Replaced by the generic [eval_spatial()]
eval_SpatialDF <- function(...) {
lifecycle::deprecate_warn("2.6.0", "eval_spatial()")
lifecycle::deprecate_stop("2.6.0", "eval_spatial()")
eval_spatial(...)
}

Expand Down
1 change: 1 addition & 0 deletions man/inlabru-package.Rd

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

0 comments on commit 2760c0d

Please sign in to comment.