Skip to content

Commit 4a1f518

Browse files
Update lifecycle badges (#268)
Both `experimental` and `deprecated` badges were added at the latest version 0.6.1 so no need for the updates #239 Only added `experimental` for the new function: `get_outputs`. --------- Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
1 parent d6bd240 commit 4a1f518

File tree

8 files changed

+27
-341
lines changed

8 files changed

+27
-341
lines changed

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
* `eval_code` uses `evaluate::evaluate` and stores returned outputs in the code's attribute.
1414
* Refactor `eval_code` method signature to allow for more flexibility when extending the `eval_code`/`within` functions.
15+
* `get_var(qenv, ...)` and `join(qenv, ...)` were hard deprecated.
1516

1617
# teal.code 0.6.1
1718

R/qenv-get_outputs.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#' Get outputs
22
#'
3-
#' @description
3+
#' @description `r lifecycle::badge("experimental")`
4+
#'
45
#' `eval_code` evaluates code silently so plots and prints don't show up in the console or graphic devices.
56
#' If one wants to use an output outside of the `qenv` (e.g. use a graph in `renderPlot`) then use `get_outputs`.
67
#' @param object (`qenv`)

R/qenv-get_var.R

Lines changed: 4 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -5,45 +5,12 @@
55
#' Instead of [get_var()] use native \R operators/functions:
66
#' `x[[name]]`, `x$name` or [get()]:
77
#'
8-
#' Retrieve variables from the `qenv` environment.
9-
#'
10-
#' @param object,x (`qenv`)
11-
#' @param var,i (`character(1)`) variable name.
12-
#'
13-
#' @return The value of required variable (`var`) within `qenv` object.
14-
#'
15-
#' @examples
16-
#' q <- qenv()
17-
#' q1 <- eval_code(q, code = quote(a <- 1))
18-
#' q2 <- eval_code(q1, code = "b <- a")
19-
#' get_var(q2, "b")
20-
#'
21-
#' @aliases get_var,qenv,character-method
22-
#' @aliases get_var,qenv.error,ANY-method
8+
#' @param ... function is deprecated.
9+
#' @param x (`qenv`)
10+
#' @param i (`character(1)`) variable name.
2311
#'
2412
#' @export
25-
setGeneric("get_var", function(object, var) {
26-
dev_suppress(object)
27-
standardGeneric("get_var")
28-
})
29-
30-
setMethod("get_var", signature = c("qenv", "character"), function(object, var) {
31-
lifecycle::deprecate_soft("0.6.0", "get_var()", "base::get()")
32-
tryCatch(
33-
get(var, envir = object@.xData, inherits = FALSE),
34-
error = function(e) {
35-
message(conditionMessage(e))
36-
NULL
37-
}
38-
)
39-
})
40-
41-
setMethod("get_var", signature = c("qenv.error", "ANY"), function(object, var) {
42-
stop(errorCondition(
43-
list(message = conditionMessage(object)),
44-
class = c("validation", "try-error", "simpleError")
45-
))
46-
})
13+
get_var <- function(...) lifecycle::deprecate_stop("0.6.0", "get_var()", "base::get()")
4714

4815
#' @rdname get_var
4916
#' @export

R/qenv-join.R

Lines changed: 4 additions & 143 deletions
Original file line numberDiff line numberDiff line change
@@ -1,152 +1,13 @@
11
#' Join `qenv` objects
22
#'
33
#' @description
4-
#' Checks and merges two `qenv` objects into one `qenv` object.
4+
#' `r lifecycle::badge("deprecated")`
5+
#' Instead of [join()] use [c()].
56
#'
6-
#' The `join()` function is superseded by the `c()` function.
7-
#'
8-
#' @details
9-
#' Any common code at the start of the `qenvs` is only placed once at the start of the joined `qenv`.
10-
#' This allows consistent behavior when joining `qenvs` which share a common ancestor.
11-
#' See below for an example.
12-
#'
13-
#' There are some situations where `join()` cannot be properly performed, such as these three scenarios:
14-
#' 1. Both `qenv` objects contain an object of the same name but are not identical.
15-
#'
16-
#' Example:
17-
#'
18-
#' ```r
19-
#' x <- eval_code(qenv(), expression(mtcars1 <- mtcars))
20-
#' y <- eval_code(qenv(), expression(mtcars1 <- mtcars['wt']))
21-
#'
22-
#' z <- c(x, y)
23-
#' # Error message will occur
24-
#' ```
25-
#' In this example, `mtcars1` object exists in both `x` and `y` objects but the content are not identical.
26-
#' `mtcars1` in the `x qenv` object has more columns than `mtcars1` in the `y qenv` object (only has one column).
27-
#'
28-
#' 2. `join()` will look for identical code elements in both `qenv` objects.
29-
#' The index position of these code elements must be the same to determine the evaluation order.
30-
#' Otherwise, `join()` will throw an error message.
31-
#'
32-
#' Example:
33-
#' ```r
34-
#' common_q <- eval_code(qenv(), expression(v <- 1))
35-
#' x <- eval_code(
36-
#' common_q,
37-
#' "x <- v"
38-
#' )
39-
#' y <- eval_code(
40-
#' common_q,
41-
#' "y <- v"
42-
#' )
43-
#' z <- eval_code(
44-
#' y,
45-
#' "z <- v"
46-
#' )
47-
#' q <- c(x, y)
48-
#' join_q <- c(q, z)
49-
#' # Error message will occur
50-
#'
51-
#' # Check the order of evaluation based on the id slot
52-
#' ```
53-
#' The error occurs because the index position of common code elements in the two objects is not the same.
54-
#'
55-
#' 3. The usage of temporary variable in the code expression could cause `join()` to fail.
56-
#'
57-
#' Example:
58-
#' ```r
59-
#' common_q <- qenv()
60-
#' x <- eval_code(
61-
#' common_q,
62-
#' "x <- numeric(0)
63-
#' for (i in 1:2) {
64-
#' x <- c(x, i)
65-
#' }"
66-
#' )
67-
#' y <- eval_code(
68-
#' common_q,
69-
#' "y <- numeric(0)
70-
#' for (i in 1:3) {
71-
#' y <- c(y, i)
72-
#' }"
73-
#' )
74-
#' q <- join(x,y)
75-
#' # Error message will occur
76-
#'
77-
#' # Check the value of temporary variable i in both objects
78-
#' x$i # Output: 2
79-
#' y$i # Output: 3
80-
#' ```
81-
#' `c()` fails to provide a proper result because of the temporary variable `i` exists
82-
#' in both objects but has different value.
83-
#' To fix this, we can set `i <- NULL` in the code expression for both objects.
84-
#' ```r
85-
#' common_q <- qenv()
86-
#' x <- eval_code(
87-
#' common_q,
88-
#' "x <- numeric(0)
89-
#' for (i in 1:2) {
90-
#' x <- c(x, i)
91-
#' }
92-
#' # dummy i variable to fix it
93-
#' i <- NULL"
94-
#' )
95-
#' y <- eval_code(
96-
#' common_q,
97-
#' "y <- numeric(0)
98-
#' for (i in 1:3) {
99-
#' y <- c(y, i)
100-
#' }
101-
#' # dummy i variable to fix it
102-
#' i <- NULL"
103-
#' )
104-
#' q <- c(x,y)
105-
#' ```
106-
#'
107-
#' @param x (`qenv`)
108-
#' @param y (`qenv`)
109-
#'
110-
#' @return `qenv` object.
111-
#'
112-
#' @examples
113-
#' q <- qenv()
114-
#' q1 <- eval_code(q, expression(iris1 <- iris, mtcars1 <- mtcars))
115-
#' q2 <- q1
116-
#' q1 <- eval_code(q1, "iris2 <- iris")
117-
#' q2 <- eval_code(q2, "mtcars2 <- mtcars")
118-
#' qq <- join(q1, q2)
119-
#' cat(get_code(qq))
120-
#'
121-
#' common_q <- eval_code(q, quote(x <- 1))
122-
#' y_q <- eval_code(common_q, quote(y <- x * 2))
123-
#' z_q <- eval_code(common_q, quote(z <- x * 3))
124-
#' join_q <- join(y_q, z_q)
125-
#' # get_code only has "x <- 1" occurring once
126-
#' cat(get_code(join_q))
127-
#'
128-
#' @include qenv-errors.R
7+
#' @param ... function is deprecated.
1298
#'
1309
#' @name join
13110
#' @rdname join
132-
#' @aliases join,qenv,qenv-method
133-
#' @aliases join,qenv,qenv.error-method
134-
#' @aliases join,qenv.error,ANY-method
13511
#'
13612
#' @export
137-
setGeneric("join", function(x, y) standardGeneric("join"))
138-
139-
setMethod("join", signature = c("qenv", "qenv"), function(x, y) {
140-
lifecycle::deprecate_soft("0.6.0", "join()", "c()")
141-
c(x, y)
142-
})
143-
144-
setMethod("join", signature = c("qenv", "qenv.error"), function(x, y) {
145-
lifecycle::deprecate_soft("0.6.0", "join()", "c()")
146-
y
147-
})
148-
149-
setMethod("join", signature = c("qenv.error", "ANY"), function(x, y) {
150-
lifecycle::deprecate_soft("0.6.0", "join()", "c()")
151-
x
152-
})
13+
join <- function(...) lifecycle::deprecate_stop("0.6.0", "join()", "c()")

man/get_outputs.Rd

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/get_var.Rd

Lines changed: 5 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)