Skip to content

Commit c922817

Browse files
committed
Update for new tidyr to avoid warnings in tests
1 parent 670e75d commit c922817

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

tests/testthat/test_nearest_neighbor_kknn.R

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,14 +132,15 @@ test_that('kknn multi-predict', {
132132
)
133133

134134
pred_multi <- multi_predict(res_xy, iris[iris_te, num_pred], neighbors = k_vals)
135-
expect_equal(pred_multi %>% unnest() %>% nrow(), length(iris_te) * length(k_vals))
135+
expect_equal(pred_multi %>% unnest(cols = c(.pred)) %>% nrow(),
136+
length(iris_te) * length(k_vals))
136137
expect_equal(pred_multi %>% nrow(), length(iris_te))
137138

138139
pred_uni <- predict(res_xy, iris[iris_te, num_pred])
139140
pred_uni_obs <-
140141
pred_multi %>%
141142
mutate(.rows = row_number()) %>%
142-
unnest() %>%
143+
unnest(cols = c(.pred)) %>%
143144
dplyr::filter(neighbors == 3) %>%
144145
arrange(.rows) %>%
145146
dplyr::select(.pred_class)
@@ -148,14 +149,15 @@ test_that('kknn multi-predict', {
148149

149150
prob_multi <- multi_predict(res_xy, iris[iris_te, num_pred],
150151
neighbors = k_vals, type = "prob")
151-
expect_equal(prob_multi %>% unnest() %>% nrow(), length(iris_te) * length(k_vals))
152+
expect_equal(prob_multi %>% unnest(cols = c(.pred)) %>% nrow(),
153+
length(iris_te) * length(k_vals))
152154
expect_equal(prob_multi %>% nrow(), length(iris_te))
153155

154156
prob_uni <- predict(res_xy, iris[iris_te, num_pred], type = "prob")
155157
prob_uni_obs <-
156158
prob_multi %>%
157159
mutate(.rows = row_number()) %>%
158-
unnest() %>%
160+
unnest(cols = c(.pred)) %>%
159161
dplyr::filter(neighbors == 3) %>%
160162
arrange(.rows) %>%
161163
dplyr::select(!!names(prob_uni))
@@ -175,14 +177,15 @@ test_that('kknn multi-predict', {
175177
)
176178

177179
pred_multi <- multi_predict(res_xy, mtcars[cars_te, -1], neighbors = k_vals)
178-
expect_equal(pred_multi %>% unnest() %>% nrow(), length(cars_te) * length(k_vals))
180+
expect_equal(pred_multi %>% unnest(cols = c(.pred)) %>% nrow(),
181+
length(cars_te) * length(k_vals))
179182
expect_equal(pred_multi %>% nrow(), length(cars_te))
180183

181184
pred_uni <- predict(res_xy, mtcars[cars_te, -1])
182185
pred_uni_obs <-
183186
pred_multi %>%
184187
mutate(.rows = row_number()) %>%
185-
unnest() %>%
188+
unnest(cols = c(.pred)) %>%
186189
dplyr::filter(neighbors == 3) %>%
187190
arrange(.rows) %>%
188191
dplyr::select(.pred)

0 commit comments

Comments
 (0)