Skip to content

Commit cec5f8f

Browse files
committedMar 10, 2024
Avoid implementing
1 parent b81566d commit cec5f8f

16 files changed

+28
-274
lines changed
 

‎NAMESPACE

-3
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,9 @@ S3method(count,duckplyr_df)
1010
S3method(cross_join,duckplyr_df)
1111
S3method(distinct,duckplyr_df)
1212
S3method(do,duckplyr_df)
13-
S3method(dplyr_col_modify,duckplyr_df)
14-
S3method(dplyr_row_slice,duckplyr_df)
1513
S3method(explain,duckplyr_df)
1614
S3method(full_join,duckplyr_df)
1715
S3method(group_by,duckplyr_df)
18-
S3method(group_data,duckplyr_df)
1916
S3method(group_indices,duckplyr_df)
2017
S3method(group_keys,duckplyr_df)
2118
S3method(group_map,duckplyr_df)

‎R/dplyr_col_modify.R

-53
This file was deleted.

‎R/dplyr_row_slice.R

-32
This file was deleted.

‎R/group_data.R

-37
This file was deleted.

‎R/overwrite.R

-3
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,9 @@ methods_overwrite_impl <- function() {
99
vctrs::s3_register("dplyr::cross_join", "data.frame", cross_join.duckplyr_df)
1010
vctrs::s3_register("dplyr::distinct", "data.frame", distinct.duckplyr_df)
1111
vctrs::s3_register("dplyr::do", "data.frame", do.duckplyr_df)
12-
vctrs::s3_register("dplyr::dplyr_col_modify", "data.frame", dplyr_col_modify.duckplyr_df)
13-
vctrs::s3_register("dplyr::dplyr_row_slice", "data.frame", dplyr_row_slice.duckplyr_df)
1412
vctrs::s3_register("dplyr::filter", "data.frame", filter.duckplyr_df)
1513
vctrs::s3_register("dplyr::full_join", "data.frame", full_join.duckplyr_df)
1614
vctrs::s3_register("dplyr::group_by", "data.frame", group_by.duckplyr_df)
17-
vctrs::s3_register("dplyr::group_data", "data.frame", group_data.duckplyr_df)
1815
vctrs::s3_register("dplyr::group_indices", "data.frame", group_indices.duckplyr_df)
1916
vctrs::s3_register("dplyr::group_keys", "data.frame", group_keys.duckplyr_df)
2017
vctrs::s3_register("dplyr::group_map", "data.frame", group_map.duckplyr_df)

‎R/restore.R

-3
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,9 @@ methods_restore_impl <- function() {
99
vctrs::s3_register("dplyr::cross_join", "data.frame", dplyr$cross_join.data.frame)
1010
vctrs::s3_register("dplyr::distinct", "data.frame", dplyr$distinct.data.frame)
1111
vctrs::s3_register("dplyr::do", "data.frame", dplyr$do.data.frame)
12-
vctrs::s3_register("dplyr::dplyr_col_modify", "data.frame", dplyr$dplyr_col_modify.data.frame)
13-
vctrs::s3_register("dplyr::dplyr_row_slice", "data.frame", dplyr$dplyr_row_slice.data.frame)
1412
vctrs::s3_register("dplyr::filter", "data.frame", dplyr$filter.data.frame)
1513
vctrs::s3_register("dplyr::full_join", "data.frame", dplyr$full_join.data.frame)
1614
vctrs::s3_register("dplyr::group_by", "data.frame", dplyr$group_by.data.frame)
17-
vctrs::s3_register("dplyr::group_data", "data.frame", dplyr$group_data.data.frame)
1815
vctrs::s3_register("dplyr::group_indices", "data.frame", dplyr$group_indices.data.frame)
1916
vctrs::s3_register("dplyr::group_keys", "data.frame", dplyr$group_keys.data.frame)
2017
vctrs::s3_register("dplyr::group_map", "data.frame", dplyr$group_map.data.frame)

‎dplyr-methods/dplyr_col_modify.txt

-24
This file was deleted.

‎dplyr-methods/dplyr_row_slice.txt

-3
This file was deleted.

‎dplyr-methods/group_data.txt

-8
This file was deleted.

‎tests/testthat/test-arrange.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ test_that("duckplyr_arrange() evaluates each pick() call on the original data (#
273273
expect_identical(out, df[c(2, 1),])
274274
})
275275

276-
test_that("duckplyr_arrange() with empty dots still calls duckplyr_dplyr_row_slice()", {
276+
test_that("duckplyr_arrange() with empty dots still calls dplyr_row_slice()", {
277277
tbl <- new_tibble(list(x = 1), nrow = 1L)
278278
foo <- structure(tbl, class = c("foo_df", class(tbl)))
279279

‎tests/testthat/test-as_duckplyr_df.R

-80
Original file line numberDiff line numberDiff line change
@@ -569,35 +569,6 @@ test_that("as_duckplyr_df() and do(data.frame(c = 1))", {
569569
expect_equal(pre, post)
570570
})
571571

572-
test_that("as_duckplyr_df() and dplyr_col_modify(list(a = 6:1))", {
573-
withr::local_envvar(DUCKPLYR_FALLBACK_FORCE = "TRUE")
574-
575-
# Data
576-
test_df <- data.frame(a = 1:6 + 0, b = 2, g = rep(1:3, 1:3))
577-
578-
# Run
579-
pre <- test_df %>% as_duckplyr_df() %>% dplyr_col_modify(list(a = 6:1))
580-
post <- test_df %>% dplyr_col_modify(list(a = 6:1)) %>% as_duckplyr_df()
581-
582-
# Compare
583-
expect_equal(pre, post)
584-
})
585-
586-
587-
test_that("as_duckplyr_df() and dplyr_col_modify(list(a = 6:1))", {
588-
withr::local_envvar(DUCKPLYR_FORCE = "FALSE")
589-
590-
# Data
591-
test_df <- data.frame(a = 1:6 + 0, b = 2, g = rep(1:3, 1:3))
592-
593-
# Run
594-
pre <- test_df %>% as_duckplyr_df() %>% dplyr_col_modify(list(a = 6:1))
595-
post <- test_df %>% dplyr_col_modify(list(a = 6:1)) %>% as_duckplyr_df()
596-
597-
# Compare
598-
expect_equal(pre, post)
599-
})
600-
601572
test_that("as_duckplyr_df() and dplyr_reconstruct(test_df)", {
602573
withr::local_envvar(DUCKPLYR_FORCE = "FALSE")
603574

@@ -614,35 +585,6 @@ test_that("as_duckplyr_df() and dplyr_reconstruct(test_df)", {
614585
expect_equal(pre, post)
615586
})
616587

617-
test_that("as_duckplyr_df() and dplyr_row_slice(1:2)", {
618-
withr::local_envvar(DUCKPLYR_FALLBACK_FORCE = "TRUE")
619-
620-
# Data
621-
test_df <- data.frame(a = 1:6 + 0, b = 2, g = rep(1:3, 1:3))
622-
623-
# Run
624-
pre <- test_df %>% as_duckplyr_df() %>% dplyr_row_slice(1:2)
625-
post <- test_df %>% dplyr_row_slice(1:2) %>% as_duckplyr_df()
626-
627-
# Compare
628-
expect_equal(pre, post)
629-
})
630-
631-
632-
test_that("as_duckplyr_df() and dplyr_row_slice(1:2)", {
633-
withr::local_envvar(DUCKPLYR_FORCE = "FALSE")
634-
635-
# Data
636-
test_df <- data.frame(a = 1:6 + 0, b = 2, g = rep(1:3, 1:3))
637-
638-
# Run
639-
pre <- test_df %>% as_duckplyr_df() %>% dplyr_row_slice(1:2)
640-
post <- test_df %>% dplyr_row_slice(1:2) %>% as_duckplyr_df()
641-
642-
# Compare
643-
expect_equal(pre, post)
644-
})
645-
646588
test_that("as_duckplyr_df() and filter(a == 1)", {
647589
withr::local_envvar(DUCKPLYR_FALLBACK_FORCE = "TRUE")
648590

@@ -754,22 +696,6 @@ test_that("as_duckplyr_df() and group_by()", {
754696
expect_equal(pre, post)
755697
})
756698

757-
test_that("as_duckplyr_df() and group_data()", {
758-
withr::local_envvar(DUCKPLYR_FORCE = "FALSE")
759-
760-
skip("Special")
761-
762-
# Data
763-
test_df <- data.frame(a = 1:6 + 0, b = 2, g = rep(1:3, 1:3))
764-
765-
# Run
766-
pre <- test_df %>% as_duckplyr_df() %>% group_data()
767-
post <- test_df %>% group_data() %>% as_duckplyr_df()
768-
769-
# Compare
770-
expect_equal(pre, post)
771-
})
772-
773699
test_that("as_duckplyr_df() and group_indices()", {
774700
skip("Special")
775701

@@ -801,8 +727,6 @@ test_that("as_duckplyr_df() and group_keys()", {
801727
})
802728

803729
test_that("as_duckplyr_df() and group_map(~ .x)", {
804-
withr::local_envvar(DUCKPLYR_FORCE = "FALSE")
805-
806730
skip("WAT")
807731

808732
# Data
@@ -817,8 +741,6 @@ test_that("as_duckplyr_df() and group_map(~ .x)", {
817741
})
818742

819743
test_that("as_duckplyr_df() and group_modify(~ .x)", {
820-
withr::local_envvar(DUCKPLYR_FORCE = "FALSE")
821-
822744
skip("Grouped")
823745

824746
# Data
@@ -865,8 +787,6 @@ test_that("as_duckplyr_df() and group_size()", {
865787
})
866788

867789
test_that("as_duckplyr_df() and group_split()", {
868-
withr::local_envvar(DUCKPLYR_FORCE = "FALSE")
869-
870790
skip("WAT")
871791

872792
# Data

‎tests/testthat/test-filter.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ test_that("filter preserves grouping", {
552552
expect_equal(group_rows(out), list_of(c(1L, 2L)))
553553
})
554554

555-
test_that("duckplyr_filter() with empty dots still calls duckplyr_dplyr_row_slice()", {
555+
test_that("duckplyr_filter() with empty dots still calls dplyr_row_slice()", {
556556
tbl <- new_tibble(list(x = 1), nrow = 1L)
557557
foo <- structure(tbl, class = c("foo_df", class(tbl)))
558558

‎tests/testthat/test-generics.R

+17-17
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,59 @@
11
test_that("row_slice recomputes groups", {
22
gf <- duckplyr_group_by(data.frame(g = c(1, 1, 2, 2, 3, 3)), g)
3-
out <- duckplyr_dplyr_row_slice(gf, c(1L, 3L, 5L))
4-
expect_equal(duckplyr_group_data(out)$.rows, list_of(1L, 2L, 3L))
3+
out <- dplyr_row_slice(gf, c(1L, 3L, 5L))
4+
expect_equal(group_data(out)$.rows, list_of(1L, 2L, 3L))
55

6-
out <- duckplyr_dplyr_row_slice(gf, c(4L, 3L))
7-
expect_equal(duckplyr_group_data(out)$.rows, list_of(c(1L, 2L)))
6+
out <- dplyr_row_slice(gf, c(4L, 3L))
7+
expect_equal(group_data(out)$.rows, list_of(c(1L, 2L)))
88
})
99

1010
test_that("row_slice preserves empty groups if requested", {
1111
gf <- duckplyr_group_by(data.frame(g = c(1, 1, 2, 2, 3, 3)), g, .drop = FALSE)
12-
out <- duckplyr_dplyr_row_slice(gf, c(3L, 4L))
13-
expect_equal(duckplyr_group_data(out)$.rows, list_of(integer(), c(1L, 2L), integer()))
12+
out <- dplyr_row_slice(gf, c(3L, 4L))
13+
expect_equal(group_data(out)$.rows, list_of(integer(), c(1L, 2L), integer()))
1414
})
1515

1616

1717
# dplyr_col_modify --------------------------------------------------------
1818

1919
test_that("empty cols returns input", {
2020
df <- data.frame(x = 1)
21-
expect_equal(duckplyr_dplyr_col_modify(df, list()), df)
21+
expect_equal(dplyr_col_modify(df, list()), df)
2222
})
2323

2424
test_that("applies tidyverse recycling rules", {
2525
expect_equal(
26-
duckplyr_dplyr_col_modify(data.frame(x = 1:2), list(y = 1)),
26+
dplyr_col_modify(data.frame(x = 1:2), list(y = 1)),
2727
data.frame(x = 1:2, y = c(1, 1))
2828
)
2929
expect_equal(
30-
duckplyr_dplyr_col_modify(data.frame(x = integer()), list(y = 1)),
30+
dplyr_col_modify(data.frame(x = integer()), list(y = 1)),
3131
data.frame(x = integer(), y = integer())
3232
)
3333

3434
expect_error(
35-
duckplyr_dplyr_col_modify(data.frame(x = 1:4), list(y = 1:2)),
35+
dplyr_col_modify(data.frame(x = 1:4), list(y = 1:2)),
3636
class = "vctrs_error_recycle_incompatible_size"
3737
)
3838
})
3939

4040
test_that("can add, remove, and replace columns", {
4141
df <- data.frame(x = 1, y = 2)
42-
expect_equal(duckplyr_dplyr_col_modify(df, list(y = NULL)), data.frame(x = 1))
43-
expect_equal(duckplyr_dplyr_col_modify(df, list(y = 3)), data.frame(x = 1, y = 3))
44-
expect_equal(duckplyr_dplyr_col_modify(df, list(z = 3)), data.frame(x = 1, y = 2, z = 3))
42+
expect_equal(dplyr_col_modify(df, list(y = NULL)), data.frame(x = 1))
43+
expect_equal(dplyr_col_modify(df, list(y = 3)), data.frame(x = 1, y = 3))
44+
expect_equal(dplyr_col_modify(df, list(z = 3)), data.frame(x = 1, y = 2, z = 3))
4545
})
4646

4747
test_that("doesn't expand row names", {
4848
df <- data.frame(x = 1:10)
49-
out <- duckplyr_dplyr_col_modify(df, list(y = 1))
49+
out <- dplyr_col_modify(df, list(y = 1))
5050

5151
expect_equal(.row_names_info(out, 1), -10)
5252
})
5353

5454
test_that("preserves existing row names", {
5555
df <- data.frame(x = c(1, 2), row.names = c("a", "b"))
56-
out <- duckplyr_dplyr_col_modify(df, list(y = 1))
56+
out <- dplyr_col_modify(df, list(y = 1))
5757
expect_equal(row.names(df), c("a", "b"))
5858
})
5959

@@ -72,11 +72,11 @@ test_that("reconstruct method gets a data frame", {
7272
df <- foobar(data.frame(x = 1))
7373

7474
seen_df <- FALSE
75-
duckplyr_dplyr_col_modify(df, list(y = 2))
75+
dplyr_col_modify(df, list(y = 2))
7676
expect_true(seen_df)
7777

7878
seen_df <- FALSE
79-
duckplyr_dplyr_row_slice(df, 1)
79+
dplyr_row_slice(df, 1)
8080
expect_true(seen_df)
8181
})
8282

‎tests/testthat/test-mutate.R

+3-3
Original file line numberDiff line numberDiff line change
@@ -303,11 +303,11 @@ test_that("mutate preserves grouping", {
303303
i <- count_regroups(out <- duckplyr_mutate(gf, x = 1))
304304
expect_equal(i, 1L)
305305
expect_equal(duckplyr_group_vars(out), "x")
306-
expect_equal(nrow(duckplyr_group_data(out)), 1)
306+
expect_equal(nrow(group_data(out)), 1)
307307

308308
i <- count_regroups(out <- duckplyr_mutate(gf, z = 1))
309309
expect_equal(i, 0)
310-
expect_equal(duckplyr_group_data(out), duckplyr_group_data(gf))
310+
expect_equal(group_data(out), group_data(gf))
311311
})
312312

313313
test_that("mutate works on zero-row grouped data frame (#596)", {
@@ -319,7 +319,7 @@ test_that("mutate works on zero-row grouped data frame (#596)", {
319319

320320
expect_type(group_rows(res), "list")
321321
expect_equal(attr(group_rows(res), "ptype"), integer())
322-
expect_equal(duckplyr_group_data(res)$b, factor(character(0)))
322+
expect_equal(group_data(res)$b, factor(character(0)))
323323
})
324324

325325
test_that("mutate preserves class of zero-row rowwise (#4224, #6303)", {

‎tests/testthat/test-transmute.R

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ test_that("transmute preserves grouping", {
99
i <- count_regroups(out <- duckplyr_transmute(gf, x = 1))
1010
expect_equal(i, 1L)
1111
expect_equal(duckplyr_group_vars(out), "x")
12-
expect_equal(nrow(duckplyr_group_data(out)), 1)
12+
expect_equal(nrow(group_data(out)), 1)
1313

1414
i <- count_regroups(out <- duckplyr_transmute(gf, z = 1))
1515
expect_equal(i, 0)
16-
expect_equal(duckplyr_group_data(out), duckplyr_group_data(gf))
16+
expect_equal(group_data(out), group_data(gf))
1717
})
1818

1919
# Empty transmutes -------------------------------------------------

‎tools/00-funs.R

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ df_methods <-
1616
filter(!grepl("_$|^as[.]tbl$", name)) %>%
1717
# special dplyr methods, won't implement
1818
filter(!(name %in% c(
19-
"same_src", # data frames can be copied into duck-frames with zero cost
19+
# Triggered after fallback, rarely called by users
20+
"dplyr_col_modify", "dplyr_row_slice", "group_data",
21+
# data frames can be copied into duck-frames with zero cost
22+
"same_src",
2023
NULL
2124
))) %>%
2225
# won't implement but want to trigger fallback message
2326
mutate(always_fallback = (name %in% c(
24-
"dplyr_col_modify",
25-
"dplyr_row_slice",
2627
"group_by",
27-
"group_data",
2828
"group_indices",
2929
"group_keys",
3030
"group_map",

0 commit comments

Comments
 (0)
Please sign in to comment.