Skip to content

Commit 0c038bf

Browse files
authored
Format with latest Air (for one sided formula tweaks) (#299)
1 parent 3f5446c commit 0c038bf

File tree

6 files changed

+82
-82
lines changed

6 files changed

+82
-82
lines changed

tests/testthat/test-furrr-options.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,11 @@ test_that("can selectively export packages on multisession", {
7171
opts <- furrr_options(packages = "dplyr")
7272

7373
expect_error(
74-
future_map(1:2, ~tibble(x = .x))
74+
future_map(1:2, ~ tibble(x = .x))
7575
)
7676

7777
expect_identical(
78-
future_map(1:2, ~tibble(x = .x), .options = opts),
78+
future_map(1:2, ~ tibble(x = .x), .options = opts),
7979
list(dplyr::tibble(x = 1L), dplyr::tibble(x = 2L))
8080
)
8181
})

tests/testthat/test-future-imap.R

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,46 @@
11
furrr_test_that("imap functions work with unnamed input", {
22
expect_identical(future_imap(1:2, ~.y), list(1L, 2L))
3-
expect_identical(future_imap_chr(1:2, ~as.character(.y)), c("1", "2"))
3+
expect_identical(future_imap_chr(1:2, ~ as.character(.y)), c("1", "2"))
44
expect_identical(future_imap_int(1:2, ~.y), c(1L, 2L))
55
expect_identical(future_imap_dbl(1:2, ~.y), c(1, 2))
6-
expect_identical(future_imap_lgl(1:2, ~identical(.y, 1L)), c(TRUE, FALSE))
7-
expect_identical(future_imap_raw(1:2, ~raw(1)), raw(2))
6+
expect_identical(future_imap_lgl(1:2, ~ identical(.y, 1L)), c(TRUE, FALSE))
7+
expect_identical(future_imap_raw(1:2, ~ raw(1)), raw(2))
88
expect_identical(
9-
future_imap_dfr(1:2, ~data.frame(x = .y)),
9+
future_imap_dfr(1:2, ~ data.frame(x = .y)),
1010
data.frame(x = c(1L, 2L))
1111
)
1212
expect_identical(
13-
future_imap_dfc(1:2, ~vctrs::new_data_frame(set_names(list(1), .y))),
13+
future_imap_dfc(1:2, ~ vctrs::new_data_frame(set_names(list(1), .y))),
1414
vctrs::new_data_frame(list(`1` = 1, `2` = 1))
1515
)
1616
})
1717

1818
furrr_test_that("imap functions work with named input", {
1919
x <- set_names(1:2, c("x", "y"))
2020
expect_identical(future_imap(x, ~.y), list(x = "x", y = "y"))
21-
expect_identical(future_imap_chr(x, ~as.character(.y)), c(x = "x", y = "y"))
21+
expect_identical(future_imap_chr(x, ~ as.character(.y)), c(x = "x", y = "y"))
2222
expect_identical(
23-
future_imap_int(x, ~if (.y == "x") 1L else 2L),
23+
future_imap_int(x, ~ if (.y == "x") 1L else 2L),
2424
c(x = 1L, y = 2L)
2525
)
2626
expect_identical(
27-
future_imap_dbl(x, ~if (.y == "x") 1 else 2),
27+
future_imap_dbl(x, ~ if (.y == "x") 1 else 2),
2828
c(x = 1, y = 2)
2929
)
3030
expect_identical(
31-
future_imap_lgl(x, ~if (.y == "x") TRUE else FALSE),
31+
future_imap_lgl(x, ~ if (.y == "x") TRUE else FALSE),
3232
c(x = TRUE, y = FALSE)
3333
)
3434
expect_identical(
35-
future_imap_raw(x, ~if (.y == "x") as.raw(1) else as.raw(2)),
35+
future_imap_raw(x, ~ if (.y == "x") as.raw(1) else as.raw(2)),
3636
set_names(as.raw(c(1L, 2L)), c("x", "y"))
3737
)
3838
expect_identical(
39-
future_imap_dfr(x, ~data.frame(x = .y)),
39+
future_imap_dfr(x, ~ data.frame(x = .y)),
4040
data.frame(x = c("x", "y"))
4141
)
4242
expect_identical(
43-
future_imap_dfc(x, ~vctrs::new_data_frame(set_names(list(1), .y))),
43+
future_imap_dfc(x, ~ vctrs::new_data_frame(set_names(list(1), .y))),
4444
vctrs::new_data_frame(list(x = 1, y = 1))
4545
)
4646
})

tests/testthat/test-future-map.R

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -78,17 +78,17 @@ furrr_test_that("future_map_dfr() works", {
7878
x <- c("a", "b", "c")
7979

8080
expect_identical(
81-
future_map_dfr(x, ~data.frame(x = .x)),
82-
map_dfr(x, ~data.frame(x = .x))
81+
future_map_dfr(x, ~ data.frame(x = .x)),
82+
map_dfr(x, ~ data.frame(x = .x))
8383
)
8484
})
8585

8686
furrr_test_that("future_map_dfc() works", {
8787
x <- c("a", "b", "c")
8888

8989
expect_identical(
90-
future_map_dfc(x, ~as.data.frame(set_names(list(1), .x))),
91-
map_dfc(x, ~as.data.frame(set_names(list(1), .x)))
90+
future_map_dfc(x, ~ as.data.frame(set_names(list(1), .x))),
91+
map_dfc(x, ~ as.data.frame(set_names(list(1), .x)))
9292
)
9393
})
9494

@@ -128,22 +128,22 @@ furrr_test_that("future_map_if() works", {
128128
x <- list("a", "b", "c")
129129

130130
expect_identical(
131-
future_map_if(x, ~.x %in% c("a", "c"), ~3),
132-
map_if(x, ~.x %in% c("a", "c"), ~3)
131+
future_map_if(x, ~ .x %in% c("a", "c"), ~3),
132+
map_if(x, ~ .x %in% c("a", "c"), ~3)
133133
)
134134
})
135135

136136
furrr_test_that("names of `.x` are retained", {
137137
x <- list(a = "a", b = "b", c = "c")
138-
expect_named(future_map_if(x, ~.x %in% c("a", "c"), ~3), c("a", "b", "c"))
138+
expect_named(future_map_if(x, ~ .x %in% c("a", "c"), ~3), c("a", "b", "c"))
139139
})
140140

141141
furrr_test_that("`.else` can be used", {
142142
x <- list("a", "b", "c")
143143

144144
expect_identical(
145-
future_map_if(x, ~.x %in% c("a", "c"), ~3, .else = ~-1),
146-
map_if(x, ~.x %in% c("a", "c"), ~3, .else = ~-1)
145+
future_map_if(x, ~ .x %in% c("a", "c"), ~3, .else = ~ -1),
146+
map_if(x, ~ .x %in% c("a", "c"), ~3, .else = ~ -1)
147147
)
148148
})
149149

@@ -156,7 +156,7 @@ furrr_test_that("Calling `~` from within `.f` works", {
156156
list(c = 5, d = 7)
157157
)
158158

159-
expect_identical(future_map(x, ~map(.x, ~.x)), x)
159+
expect_identical(future_map(x, ~ map(.x, ~.x)), x)
160160
})
161161

162162
furrr_test_that("Calling `~` from within `.f` inside a `mutate()` works (#7, #123)", {
@@ -168,7 +168,7 @@ furrr_test_that("Calling `~` from within `.f` inside a `mutate()` works (#7, #12
168168
df <- dplyr::tibble(x = x)
169169

170170
expect_identical(
171-
dplyr::mutate(df, x = future_map(x, ~map(.x, ~.x))),
171+
dplyr::mutate(df, x = future_map(x, ~ map(.x, ~.x))),
172172
df
173173
)
174174
})
@@ -178,11 +178,11 @@ furrr_test_that("globals in `.x` are found (#16)", {
178178

179179
x <- list(c(1, 2, NA), c(2, 3, 4))
180180

181-
fns1 <- map(x, ~purrr::partial(fn, x = .x))
182-
fns2 <- map(x, ~function() fn(.x))
181+
fns1 <- map(x, ~ purrr::partial(fn, x = .x))
182+
fns2 <- map(x, ~ function() fn(.x))
183183

184-
expect_identical(future_map_dbl(fns1, ~.x()), c(3, 9))
185-
expect_identical(future_map_dbl(fns2, ~.x()), c(3, 9))
184+
expect_identical(future_map_dbl(fns1, ~ .x()), c(3, 9))
185+
expect_identical(future_map_dbl(fns2, ~ .x()), c(3, 9))
186186
})
187187

188188
test_that("globals in `.x` are only exported to workers that use them", {
@@ -212,7 +212,7 @@ test_that("globals in `.x` are only exported to workers that use them", {
212212
x <- list(my_wrapper1, my_wrapper2)
213213

214214
expect_identical(
215-
future_map_lgl(.x = x, .f = ~.x(c(1, NA))),
215+
future_map_lgl(.x = x, .f = ~ .x(c(1, NA))),
216216
c(TRUE, FALSE)
217217
)
218218
})

tests/testthat/test-future-map2.R

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
furrr_test_that("future_map2() matches map2() for simple cases", {
55
expect_identical(
6-
future_map2(1:3, 4:6, ~.x + .y),
7-
map2(1:3, 4:6, ~.x + .y)
6+
future_map2(1:3, 4:6, ~ .x + .y),
7+
map2(1:3, 4:6, ~ .x + .y)
88
)
99
})
1010

@@ -27,8 +27,8 @@ furrr_test_that("future_map2_dbl() works", {
2727
y <- c(4, 5, 6)
2828

2929
expect_identical(
30-
future_map2_dbl(x, y, ~.x + .y),
31-
map2_dbl(x, y, ~.x + .y)
30+
future_map2_dbl(x, y, ~ .x + .y),
31+
map2_dbl(x, y, ~ .x + .y)
3232
)
3333
})
3434

@@ -37,8 +37,8 @@ furrr_test_that("future_map2_int() works", {
3737
y <- c(4L, 5L, 6L)
3838

3939
expect_identical(
40-
future_map2_int(x, y, ~.x + .y),
41-
map2_int(x, y, ~.x + .y)
40+
future_map2_int(x, y, ~ .x + .y),
41+
map2_int(x, y, ~ .x + .y)
4242
)
4343
})
4444

@@ -47,8 +47,8 @@ furrr_test_that("future_map2_lgl() works", {
4747
y <- c(FALSE, TRUE, TRUE)
4848

4949
expect_identical(
50-
future_map2_lgl(x, y, ~.x || .y),
51-
map2_lgl(x, y, ~.x || .y)
50+
future_map2_lgl(x, y, ~ .x || .y),
51+
map2_lgl(x, y, ~ .x || .y)
5252
)
5353
})
5454

@@ -86,8 +86,8 @@ furrr_test_that("future_map2_dfr() works", {
8686
y <- c("d", "e", "f")
8787

8888
expect_identical(
89-
future_map2_dfr(x, y, ~data.frame(x = .x, y = .y)),
90-
map2_dfr(x, y, ~data.frame(x = .x, y = .y))
89+
future_map2_dfr(x, y, ~ data.frame(x = .x, y = .y)),
90+
map2_dfr(x, y, ~ data.frame(x = .x, y = .y))
9191
)
9292
})
9393

@@ -96,8 +96,8 @@ furrr_test_that("future_map2_dfc() works", {
9696
y <- c("d", "e", "f")
9797

9898
expect_identical(
99-
future_map2_dfc(x, y, ~as.data.frame(set_names(list(.x), .y))),
100-
map2_dfc(x, y, ~as.data.frame(set_names(list(.x), .y)))
99+
future_map2_dfc(x, y, ~ as.data.frame(set_names(list(.x), .y))),
100+
map2_dfc(x, y, ~ as.data.frame(set_names(list(.x), .y)))
101101
)
102102
})
103103

@@ -118,34 +118,34 @@ furrr_test_that("atomic variants work with size zero input", {
118118

119119
furrr_test_that("size one recycling works", {
120120
expect_identical(
121-
future_map2(1, 1:2, ~c(.x, .y)),
121+
future_map2(1, 1:2, ~ c(.x, .y)),
122122
list(c(1, 1), c(1, 2))
123123
)
124124

125125
expect_identical(
126-
future_map2(1:2, 1, ~c(.x, .y)),
126+
future_map2(1:2, 1, ~ c(.x, .y)),
127127
list(c(1, 1), c(2, 1))
128128
)
129129

130130
expect_identical(
131-
future_map2(integer(), 1, ~c(.x, .y)),
131+
future_map2(integer(), 1, ~ c(.x, .y)),
132132
list()
133133
)
134134

135135
expect_identical(
136-
future_map2(1, integer(), ~c(.x, .y)),
136+
future_map2(1, integer(), ~ c(.x, .y)),
137137
list()
138138
)
139139
})
140140

141141
furrr_test_that("generally can't recycle to size zero", {
142142
expect_error(
143-
future_map2(1:2, integer(), ~c(.x, .y)),
143+
future_map2(1:2, integer(), ~ c(.x, .y)),
144144
"Can't recycle"
145145
)
146146

147147
expect_error(
148-
future_map2(integer(), 1:2, ~c(.x, .y)),
148+
future_map2(integer(), 1:2, ~ c(.x, .y)),
149149
"Can't recycle"
150150
)
151151
})
@@ -159,18 +159,18 @@ furrr_test_that("globals in `.x` and `.y` are found (#16)", {
159159

160160
x <- list(c(1, 2, NA), c(2, 3, 4))
161161

162-
fns1 <- map(x, ~purrr::partial(fn1, x = .x))
163-
fns2 <- map(x, ~purrr::partial(fn2, x = .x))
162+
fns1 <- map(x, ~ purrr::partial(fn1, x = .x))
163+
fns2 <- map(x, ~ purrr::partial(fn2, x = .x))
164164

165165
expect_identical(
166-
future_map2(fns1, fns2, ~c(.x(), .y())),
166+
future_map2(fns1, fns2, ~ c(.x(), .y())),
167167
list(c(3, NA), c(9, 9))
168168
)
169169
})
170170

171171
furrr_test_that("chunk balancing is correct after a recycle (#30)", {
172172
expect_identical(
173-
future_map2(1, 1:4, ~c(.x, .y)),
173+
future_map2(1, 1:4, ~ c(.x, .y)),
174174
list(c(1, 1), c(1, 2), c(1, 3), c(1, 4))
175175
)
176176
})

tests/testthat/test-future-modify.R

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ furrr_test_that("future_modify() is not stable when returning `NULL`", {
1515
expect_identical(
1616
future_modify(
1717
list(1, 2),
18-
~if (.x == 1) {
18+
~ if (.x == 1) {
1919
NULL
2020
} else {
2121
.x
@@ -65,35 +65,35 @@ furrr_test_that("future_modify_at() variants works", {
6565
# future_modify_if()
6666

6767
furrr_test_that("future_modify_if() default works", {
68-
expect_identical(future_modify_if(list(1, 2), ~.x == 1, ~3), list(3, 2))
68+
expect_identical(future_modify_if(list(1, 2), ~ .x == 1, ~3), list(3, 2))
6969
expect_identical(
70-
future_modify_if(data.frame(x = 1, y = 2), ~.x == 1, ~3),
70+
future_modify_if(data.frame(x = 1, y = 2), ~ .x == 1, ~3),
7171
data.frame(x = 3, y = 2)
7272
)
7373
})
7474

7575
furrr_test_that("future_modify_if() `.else` works for default", {
7676
expect_identical(
77-
future_modify_if(list(1, 2, 1, 4), ~.x == 1, ~3, .else = ~4),
77+
future_modify_if(list(1, 2, 1, 4), ~ .x == 1, ~3, .else = ~4),
7878
list(3, 4, 3, 4)
7979
)
8080
})
8181

8282
furrr_test_that("future_modify_if() variants works", {
8383
expect_identical(
84-
future_modify_if(c(1L, 2L, 3L), ~.x == 1L, ~2L, .else = ~3L),
84+
future_modify_if(c(1L, 2L, 3L), ~ .x == 1L, ~2L, .else = ~3L),
8585
c(2L, 3L, 3L)
8686
)
8787
expect_identical(
88-
future_modify_if(c(1, 2, 3), ~.x == 1, ~2, .else = ~3),
88+
future_modify_if(c(1, 2, 3), ~ .x == 1, ~2, .else = ~3),
8989
c(2, 3, 3)
9090
)
9191
expect_identical(
92-
future_modify_if(c("a", "b", "c"), ~.x == "a", toupper, .else = ~"d"),
92+
future_modify_if(c("a", "b", "c"), ~ .x == "a", toupper, .else = ~"d"),
9393
c("A", "d", "d")
9494
)
9595
expect_identical(
96-
future_modify_if(c(TRUE, FALSE, TRUE), ~.x == TRUE, ~TRUE, .else = ~NA),
96+
future_modify_if(c(TRUE, FALSE, TRUE), ~ .x == TRUE, ~TRUE, .else = ~NA),
9797
c(TRUE, NA, TRUE)
9898
)
9999
})

0 commit comments

Comments
 (0)