Skip to content

Commit 502491c

Browse files
Fix 'crossmap' unit tests on xwalk() and future_xwalk()
1 parent e299718 commit 502491c

4 files changed

Lines changed: 19 additions & 22 deletions

File tree

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Package: progressify
2-
Version: 0.1.0-9003
2+
Version: 0.1.0-9004
33
Title: Progress Reporting of Common Functions via One Magic Function
44
Description: The progressify() function rewrites (transpiles) calls to sequential and parallel map-reduce functions such as base::lapply(), purrr::map(), foreach::foreach(), and plyr::llply() to signal progress updates. By combining this function with R's native pipe operator, you have a straightforward way to report progress on iterative computations with minimal refactoring, e.g. 'lapply(x, fcn) |> progressify()' and 'purrr::map(x, fcn) |> progressify()'. It is compatible with the 'futurize' package for parallelization, e.g. 'lapply(x, fcn) |> progressify() |> futurize()' and 'purrr::map(x, fcn) |> futurize() |> progressify()'.
55
Authors@R: c(

inst/testme/test-progressify-crossmap-future.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ for (kk in seq_along(exprs)) {
6666
res_walk <- list()
6767
truth_walk <- list()
6868

69-
expr <- quote(future_xwalk(xs, function(x, y) { res_walk[[length(res_walk) + 1L]] <<- x * y }))
69+
expr <- quote(future_xwalk(xs, function(x, y) { list(x = x, y = y) }))
7070
truth <- eval(expr)
7171
res_walk_truth <- res_walk
7272

inst/testme/test-progressify-crossmap.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ for (kk in seq_along(exprs)) {
6666
res_walk <- list()
6767
truth_walk <- list()
6868

69-
expr <- quote(xwalk(xs, function(x, y) { res_walk[[length(res_walk) + 1L]] <<- x * y }))
69+
expr <- quote(xwalk(xs, function(x, y) { list(x = x, y = y) }))
7070
truth <- eval(expr)
7171
res_walk_truth <- res_walk
7272

inst/testme/test-progressify-futurize-crossmap.R

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -81,26 +81,23 @@ for (kk in seq_along(exprs)) {
8181
## -------------------------------------------------------
8282
## xwalk
8383
## -------------------------------------------------------
84-
## FIXME
85-
if (FALSE) {
86-
for (pipe in c("progressify_futurize", "futurize_progressify")) {
87-
res_walk <- list()
88-
89-
expr <- quote(xwalk(xs, function(x, y) { res_walk[[length(res_walk) + 1L]] <<- x * y }))
90-
truth <- eval(expr)
91-
res_walk_truth <- res_walk
92-
93-
res_walk <- list()
94-
if (pipe == "progressify_futurize") {
95-
expr_f <- bquote(.(expr) |> progressify() |> futurize())
96-
} else {
97-
expr_f <- bquote(.(expr) |> futurize() |> progressify())
98-
}
99-
message(sprintf("--- xwalk %s ---", pipe))
100-
print(expr_f)
101-
stopifnot(all.equal(res_walk, res_walk_truth))
102-
stopifnot(identical(res_walk, res_walk_truth))
84+
for (pipe in c("progressify_futurize", "futurize_progressify")) {
85+
res_walk <- list()
86+
87+
expr <- quote(xwalk(xs, function(x, y) { invisible(list(x = x, y = y)) }))
88+
truth <- eval(expr)
89+
res_walk_truth <- res_walk
90+
91+
res_walk <- list()
92+
if (pipe == "progressify_futurize") {
93+
expr_f <- bquote(.(expr) |> progressify() |> futurize())
94+
} else {
95+
expr_f <- bquote(.(expr) |> futurize() |> progressify())
10396
}
97+
message(sprintf("--- xwalk %s ---", pipe))
98+
print(expr_f)
99+
stopifnot(all.equal(res_walk, res_walk_truth))
100+
stopifnot(identical(res_walk, res_walk_truth))
104101
}
105102

106103

0 commit comments

Comments
 (0)