Skip to content

Commit 8b28ac6

Browse files
krlmlrgithub-actions[bot]
authored andcommitted
[create-pull-request] automated change
1 parent 51ba55e commit 8b28ac6

File tree

10 files changed

+65
-23
lines changed

10 files changed

+65
-23
lines changed

tests/testthat/_snaps/dplyr-case-match.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,23 @@
44
case_match(1)
55
Condition
66
Error in `case_match()`:
7-
! At least one condition must be supplied.
7+
! `...` can't be empty.
88

99
---
1010

1111
Code
1212
case_match(1, NULL)
1313
Condition
1414
Error in `case_match()`:
15-
! At least one condition must be supplied.
15+
! `...` can't be empty.
1616

1717
# `.default` is part of common type computation
1818

1919
Code
2020
case_match(1, 1 ~ 1L, .default = "x")
2121
Condition
2222
Error in `case_match()`:
23-
! Can't combine `..1 (right)` <integer> and `.default` <character>.
23+
! Can't combine <integer> and `.default` <character>.
2424

2525
# `NULL` formula element throws meaningful error
2626

@@ -29,6 +29,7 @@
2929
Condition
3030
Error in `case_match()`:
3131
! `..1 (right)` must be a vector, not `NULL`.
32+
i Read our FAQ about scalar types (`?vctrs::faq_error_scalar_type`) to learn more.
3233

3334
---
3435

@@ -37,6 +38,7 @@
3738
Condition
3839
Error in `case_match()`:
3940
! `..1 (left)` must be a vector, not `NULL`.
41+
i Read our FAQ about scalar types (`?vctrs::faq_error_scalar_type`) to learn more.
4042

4143
# throws chained errors when formula evaluation fails
4244

tests/testthat/_snaps/dplyr-case-when.md

Lines changed: 47 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
case_when(FALSE ~ 1L, .default = 2:5)
55
Condition
66
Error in `case_when()`:
7-
! `.default` must have size 1, not size 4.
7+
! Can't recycle `.default` (size 4) to size 1.
88

99
# `.default` is part of common type computation
1010

1111
Code
1212
case_when(TRUE ~ 1L, .default = "x")
1313
Condition
1414
Error in `case_when()`:
15-
! Can't combine `..1 (right)` <integer> and `.default` <character>.
15+
! Can't combine <integer> and `.default` <character>.
1616

1717
# passes through `.size` correctly
1818

@@ -35,8 +35,27 @@
3535
Code
3636
case_when(1 ~ NULL)
3737
Condition
38-
Error in `case_when()`:
39-
! `..1 (right)` must be a vector, not `NULL`.
38+
Warning:
39+
Calling `case_when()` with size 1 LHS inputs and size >1 RHS inputs was deprecated in dplyr 1.2.0.
40+
i This `case_when()` statement can result in subtle silent bugs and is very inefficient.
41+
42+
Please use a series of if statements instead:
43+
44+
```
45+
# Previously
46+
case_when(scalar_lhs1 ~ rhs1, scalar_lhs2 ~ rhs2, .default = default)
47+
48+
# Now
49+
if (scalar_lhs1) {
50+
rhs1
51+
} else if (scalar_lhs2) {
52+
rhs2
53+
} else {
54+
default
55+
}
56+
```
57+
Error in `case_when()`:
58+
! `..1 (left)` must be a logical vector, not an empty numeric vector.
4059

4160
---
4261

@@ -73,7 +92,7 @@
7392
Output
7493
<error/vctrs_error_incompatible_size>
7594
Error in `case_when()`:
76-
! Can't recycle `..1 (left)` (size 2) to match `..1 (right)` (size 3).
95+
! Can't recycle `..1 (right)` (size 3) to match `..2 (right)` (size 2).
7796
Code
7897
(expect_error(case_when(c(TRUE, FALSE) ~ 1, c(FALSE, TRUE, FALSE) ~ 2, c(FALSE,
7998
TRUE, FALSE, NA) ~ 3)))
@@ -83,6 +102,26 @@
83102
! Can't recycle `..1 (left)` (size 2) to match `..2 (left)` (size 3).
84103
Code
85104
(expect_error(case_when(50 ~ 1:3)))
105+
Condition
106+
Warning:
107+
Calling `case_when()` with size 1 LHS inputs and size >1 RHS inputs was deprecated in dplyr 1.2.0.
108+
i This `case_when()` statement can result in subtle silent bugs and is very inefficient.
109+
110+
Please use a series of if statements instead:
111+
112+
```
113+
# Previously
114+
case_when(scalar_lhs1 ~ rhs1, scalar_lhs2 ~ rhs2, .default = default)
115+
116+
# Now
117+
if (scalar_lhs1) {
118+
rhs1
119+
} else if (scalar_lhs2) {
120+
rhs2
121+
} else {
122+
default
123+
}
124+
```
86125
Output
87126
<error/rlang_error>
88127
Error in `case_when()`:
@@ -104,17 +143,17 @@
104143
Output
105144
<error/rlang_error>
106145
Error in `case_when()`:
107-
! At least one condition must be supplied.
146+
! `...` can't be empty.
108147
Code
109148
(expect_error(case_when(NULL)))
110149
Output
111150
<error/rlang_error>
112151
Error in `case_when()`:
113-
! At least one condition must be supplied.
152+
! `...` can't be empty.
114153
Code
115154
(expect_error(case_when(~ 1:2)))
116155
Output
117156
<error/rlang_error>
118157
Error in `case_when()`:
119-
! Case 1 (`~1:2`) must be a two-sided formula.
158+
! Case 1 (`~1:2`) must be a two-sided formula, not a one-sided formula.
120159

tests/testthat/_snaps/dplyr-coalesce.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
coalesce(NULL, NULL)
3636
Condition
3737
Error in `coalesce()`:
38-
! `...` can't be empty.
38+
! `...` must contain at least 1 non-`NULL` value.
3939

4040
# inputs must be vectors
4141

@@ -44,6 +44,7 @@
4444
Condition
4545
Error in `coalesce()`:
4646
! `..2` must be a vector, not an environment.
47+
i Read our FAQ about scalar types (`?vctrs::faq_error_scalar_type`) to learn more.
4748

4849
# names in error messages are indexed correctly
4950

tests/testthat/_snaps/dplyr-consecutive-id.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,5 @@
2020
Condition
2121
Error in `consecutive_id()`:
2222
! `..1` must be a vector, not a function.
23+
i Read our FAQ about scalar types (`?vctrs::faq_error_scalar_type`) to learn more.
2324

tests/testthat/_snaps/dplyr-desc.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@
55
Condition
66
Error in `desc()`:
77
! `x` must be a vector, not a function.
8+
i Read our FAQ about scalar types (`?vctrs::faq_error_scalar_type`) to learn more.
89

tests/testthat/_snaps/dplyr-if-else.md

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,23 @@
2828
if_else(x < 2, bad, x)
2929
Condition
3030
Error in `if_else()`:
31-
! `true` must have size 3, not size 2.
31+
! Can't recycle `true` (size 2) to size 3.
3232

3333
---
3434

3535
Code
3636
if_else(x < 2, x, bad)
3737
Condition
3838
Error in `if_else()`:
39-
! `false` must have size 3, not size 2.
39+
! Can't recycle `false` (size 2) to size 3.
4040

4141
---
4242

4343
Code
4444
if_else(x < 2, x, x, missing = bad)
4545
Condition
4646
Error in `if_else()`:
47-
! `missing` must have size 3, not size 2.
47+
! Can't recycle `missing` (size 2) to size 3.
4848

4949
# must have empty dots
5050

@@ -66,11 +66,3 @@
6666
! Can't convert from `false` <double> to <integer> due to loss of precision.
6767
* Locations: 1
6868

69-
# `size` overrides the `condition` size
70-
71-
Code
72-
if_else(TRUE, 1, 2, size = 2)
73-
Condition
74-
Error in `if_else()`:
75-
! `condition` must have size 2, not size 1.
76-

tests/testthat/_snaps/dplyr-lead-lag.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
Condition
6060
Error in `lead()`:
6161
! `x` must be a vector, not an environment.
62+
i Read our FAQ about scalar types (`?vctrs::faq_error_scalar_type`) to learn more.
6263

6364
---
6465

@@ -67,4 +68,5 @@
6768
Condition
6869
Error in `lag()`:
6970
! `x` must be a vector, not an environment.
71+
i Read our FAQ about scalar types (`?vctrs::faq_error_scalar_type`) to learn more.
7072

tests/testthat/_snaps/dplyr-n-distinct.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@
1717
Condition
1818
Error in `n_distinct()`:
1919
! `..1` must be a vector, not a function.
20+
i Read our FAQ about scalar types (`?vctrs::faq_error_scalar_type`) to learn more.
2021

tests/testthat/_snaps/dplyr-na-if.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
Condition
3939
Error in `na_if()`:
4040
! `x` must be a vector, not an environment.
41+
i Read our FAQ about scalar types (`?vctrs::faq_error_scalar_type`) to learn more.
4142

4243
---
4344

@@ -46,4 +47,5 @@
4647
Condition
4748
Error in `na_if()`:
4849
! `y` must be a vector, not an environment.
50+
i Read our FAQ about scalar types (`?vctrs::faq_error_scalar_type`) to learn more.
4951

tests/testthat/_snaps/dplyr-nth-value.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
Condition
6262
Error in `vec_size()`:
6363
! `x` must be a vector, not an environment.
64+
i Read our FAQ about scalar types (`?vctrs::faq_error_scalar_type`) to learn more.
6465

6566
# `order_by` must be the same size as `x`
6667

0 commit comments

Comments
 (0)