Skip to content

Commit bd19dea

Browse files
authored
remove verify-warning from the code (#334)
linking to the discussion insightsengineering/teal#1342 (comment) - removed verification-warning message from get_code - ~~added is_verified method to possibly handle `@verified == FALSE` by external process. I'm fine to use `@verified` directly in `teal` - I'm happy also to remove `is_verified` if suggested in review.~~
1 parent 98a58ad commit bd19dea

File tree

5 files changed

+10
-24
lines changed

5 files changed

+10
-24
lines changed

NEWS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
- do not allow to set a dataset name that do not exist in `teal_data` environment.
1111
- `teal_data` no longer set default `datanames()` based on `join_keys` names - it uses only data names.
1212

13+
### Miscellaneous
14+
15+
- `get_code` no longer adds `warning` message about failed verification.
16+
1317
# teal.data 0.6.0
1418

1519
### Enhancements

R/teal_data-get_code.R

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#'
55
#' Retrieve code stored in `@code`, which (in principle) can be used to recreate all objects found in `@env`.
66
#' Use `datanames` to limit the code to one or more of the datasets enumerated in `@datanames`.
7-
#' If the code has not passed verification (with [`verify()`]), a warning will be prepended.
87
#'
98
#' @section Extracting dataset-specific code:
109
#' When `datanames` is specified, the code returned will be limited to the lines needed to _create_
@@ -114,10 +113,6 @@ setMethod("get_code", signature = "teal_data", definition = function(object, dep
114113
object@code
115114
}
116115

117-
if (!object@verified) {
118-
code <- c("warning('Code was not verified for reproducibility.')", code)
119-
}
120-
121116
if (deparse) {
122117
if (length(code) == 0) {
123118
code

man/get_code.Rd

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

tests/testthat/test-get_code.R

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
warning_message <- "warning('Code was not verified for reproducibility.')"
2-
31
testthat::test_that("handles empty @code slot", {
42
testthat::expect_identical(
53
get_code(teal_data(a = 1, code = character(0)), datanames = "a"),
6-
warning_message
4+
character(0)
75
)
86
testthat::expect_identical(
97
get_code(teal_data(a = 1, code = ""), datanames = "a"),
10-
paste0(warning_message, "\n")
8+
""
119
)
1210
})
1311

@@ -20,7 +18,7 @@ testthat::test_that("handles the code without symbols on rhs", {
2018

2119
testthat::expect_identical(
2220
get_code(teal_data(a = 5, code = code), datanames = "a"),
23-
paste(warning_message, "a <- 5", sep = "\n")
21+
"a <- 5"
2422
)
2523
})
2624

@@ -29,7 +27,7 @@ testthat::test_that("handles the code included in curly brackets", {
2927

3028
testthat::expect_identical(
3129
get_code(teal_data(a = 5, code = code), datanames = "a"),
32-
paste(warning_message, "a <- 5", sep = "\n")
30+
"a <- 5"
3331
)
3432
})
3533

@@ -545,11 +543,7 @@ testthat::test_that("detects occurrence of a function definition with a @linksto
545543
tdata <- teal_data(code = code)
546544
testthat::expect_identical(
547545
get_code(tdata, datanames = "x"),
548-
paste(
549-
warning_message,
550-
"foo <- function() {\n env <- parent.frame()\n env$x <- 0\n}\nfoo()",
551-
sep = "\n"
552-
)
546+
"foo <- function() {\n env <- parent.frame()\n env$x <- 0\n}\nfoo()"
553547
)
554548
})
555549
# $ ---------------------------------------------------------------------------------------------------------------
@@ -608,7 +602,6 @@ testthat::test_that("understands @ usage and do not treat rhs of @ as objects (o
608602
testthat::expect_identical(
609603
get_code(tdata, datanames = "x"),
610604
paste(
611-
warning_message,
612605
'setClass("aclass", slots = c(a = "numeric", x = "numeric", y = "numeric"))',
613606
'x <- new("aclass", a = 1:3, x = 1:3, y = 1:3)',
614607
sep = "\n"
@@ -617,7 +610,6 @@ testthat::test_that("understands @ usage and do not treat rhs of @ as objects (o
617610
testthat::expect_identical(
618611
get_code(tdata, datanames = "a"),
619612
paste(
620-
warning_message,
621613
'setClass("aclass", slots = c(a = "numeric", x = "numeric", y = "numeric"))',
622614
'x <- new("aclass", a = 1:3, x = 1:3, y = 1:3)',
623615
'a <- new("aclass", a = 1:3, x = 1:3, y = 1:3)',
@@ -646,7 +638,6 @@ testthat::test_that("library() and require() are always returned", {
646638
testthat::expect_identical(
647639
get_code(tdata, datanames = "x"),
648640
paste(
649-
warning_message,
650641
"library(random.cdisc.data)",
651642
"require(dplyr)",
652643
"library(MultiAssayExperiment)",
@@ -672,7 +663,6 @@ testthat::test_that("data() call is returned when data name is provided as is",
672663
testthat::expect_identical(
673664
get_code(tdata, datanames = "x"),
674665
paste(
675-
warning_message,
676666
"library(random.cdisc.data)",
677667
"require(dplyr)",
678668
"library(MultiAssayExperiment)",
@@ -696,7 +686,6 @@ testthat::test_that("data() call is returned when data name is provided as a cha
696686
testthat::expect_identical(
697687
get_code(tdata, datanames = "z"),
698688
paste(
699-
warning_message,
700689
"library(random.cdisc.data)",
701690
"require(dplyr)",
702691
"library(MultiAssayExperiment)",

vignettes/teal-data-reproducibility.Rmd

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ data_with_data <- teal_data(i = head(iris), code = "i <- head(iris)")
4545
data_with_data # is unverified
4646
data_with_data <- within(data_with_data, i$rand <- sample(nrow(i)))
4747
data_with_data # remains unverified
48-
cat(get_code(data_with_data)) # warning is prepended
4948
```
5049

5150
### Verification process
@@ -69,7 +68,7 @@ data_right <- teal_data(
6968
data <- data.frame(x = 11:20)
7069
data$id <- seq_len(nrow(data))
7170
})
72-
)
71+
) # is unverified
7372
(data_right_verified <- verify(data_right)) # returns verified object
7473
```
7574

0 commit comments

Comments
 (0)