Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor!: remove $rep_extend() #1028

Merged
merged 3 commits into from
Apr 13, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@
- `<Series>$to_r_list()` is renamed `<Series>$to_list()` (#938).
- Removed `<Series>$to_r_vector()` which was an old alias for
`<Series>$to_vector()` (#938).
- Removed `<Expr>$rep_extend()`, which was an experimental method created at the
early stage of this package and not existing in other language APIs (#1028).
etiennebacher marked this conversation as resolved.
Show resolved Hide resolved
- In `$str$contains()`, the arguments `literal` and `strict` should be named arguments (#982).
- In `$str$contains_any()`, the `ascii_case_insensitive` argument must be named (#986).
- In `$str$count_matches()`, `$str$replace()` and `$str$replace_all()`,
Expand Down
15 changes: 0 additions & 15 deletions R/expr__expr.R
Original file line number Diff line number Diff line change
Expand Up @@ -3034,21 +3034,6 @@ Expr_rep = function(n, rechunk = TRUE) {
unwrap("in $rep()")
}

#' Extend a Series by repeating values
#'
#' @param expr Expr or something coercible to an Expr.
#' @inheritParams Expr_rep
#' @param upcast If `TRUE` (default), non identical types will be cast to common
#' supertype if there is any. If `FALSE` or no common super type, having
#' different types will throw an error.
#' @return Expr
#' @examples
#' pl$select(pl$lit(c(1, 2, 3))$rep_extend(1:3, n = 5))
Expr_rep_extend = function(expr, n, rechunk = TRUE, upcast = TRUE) {
other = wrap_e(expr)$rep(n, rechunk = FALSE)
new = .pr$Expr$append(self, other, upcast)
if (rechunk) new$rechunk() else new
}

#' Convert an Expr to R output
#'
Expand Down
28 changes: 0 additions & 28 deletions man/Expr_rep_extend.Rd

This file was deleted.

148 changes: 73 additions & 75 deletions tests/testthat/_snaps/after-wrappers.md
Original file line number Diff line number Diff line change
Expand Up @@ -249,24 +249,24 @@
[115] "peak_max" "peak_min" "pow"
[118] "print" "product" "quantile"
[121] "rank" "rechunk" "reinterpret"
[124] "rep" "rep_extend" "repeat_by"
[127] "replace" "reshape" "reverse"
[130] "rle" "rle_id" "rolling"
[133] "rolling_max" "rolling_mean" "rolling_median"
[136] "rolling_min" "rolling_quantile" "rolling_skew"
[139] "rolling_std" "rolling_sum" "rolling_var"
[142] "round" "sample" "search_sorted"
[145] "set_sorted" "shift" "shift_and_fill"
[148] "shrink_dtype" "shuffle" "sign"
[151] "sin" "sinh" "skew"
[154] "slice" "sort" "sort_by"
[157] "sqrt" "std" "str"
[160] "struct" "sub" "sum"
[163] "tail" "tan" "tanh"
[166] "to_physical" "to_r" "to_series"
[169] "to_struct" "top_k" "unique"
[172] "unique_counts" "upper_bound" "value_counts"
[175] "var" "xor"
[124] "rep" "repeat_by" "replace"
[127] "reshape" "reverse" "rle"
[130] "rle_id" "rolling" "rolling_max"
[133] "rolling_mean" "rolling_median" "rolling_min"
[136] "rolling_quantile" "rolling_skew" "rolling_std"
[139] "rolling_sum" "rolling_var" "round"
[142] "sample" "search_sorted" "set_sorted"
[145] "shift" "shift_and_fill" "shrink_dtype"
[148] "shuffle" "sign" "sin"
[151] "sinh" "skew" "slice"
[154] "sort" "sort_by" "sqrt"
[157] "std" "str" "struct"
[160] "sub" "sum" "tail"
[163] "tan" "tanh" "to_physical"
[166] "to_r" "to_series" "to_struct"
[169] "top_k" "unique" "unique_counts"
[172] "upper_bound" "value_counts" "var"
[175] "xor"

---

Expand Down Expand Up @@ -494,25 +494,24 @@
[115] "pct_change" "peak_max" "peak_min"
[118] "pow" "print" "product"
[121] "quantile" "rank" "rechunk"
[124] "reinterpret" "rep" "rep_extend"
[127] "repeat_by" "replace" "reshape"
[130] "reverse" "rle" "rle_id"
[133] "rolling" "rolling_max" "rolling_mean"
[136] "rolling_median" "rolling_min" "rolling_quantile"
[139] "rolling_skew" "rolling_std" "rolling_sum"
[142] "rolling_var" "round" "sample"
[145] "search_sorted" "set_sorted" "shift"
[148] "shift_and_fill" "shrink_dtype" "shuffle"
[151] "sign" "sin" "sinh"
[154] "skew" "slice" "sort"
[157] "sort_by" "sqrt" "std"
[160] "str" "struct" "sub"
[163] "sum" "tail" "tan"
[166] "tanh" "to_physical" "to_r"
[169] "to_series" "to_struct" "top_k"
[172] "unique" "unique_counts" "upper_bound"
[175] "value_counts" "var" "when"
[178] "xor"
[124] "reinterpret" "rep" "repeat_by"
[127] "replace" "reshape" "reverse"
[130] "rle" "rle_id" "rolling"
[133] "rolling_max" "rolling_mean" "rolling_median"
[136] "rolling_min" "rolling_quantile" "rolling_skew"
[139] "rolling_std" "rolling_sum" "rolling_var"
[142] "round" "sample" "search_sorted"
[145] "set_sorted" "shift" "shift_and_fill"
[148] "shrink_dtype" "shuffle" "sign"
[151] "sin" "sinh" "skew"
[154] "slice" "sort" "sort_by"
[157] "sqrt" "std" "str"
[160] "struct" "sub" "sum"
[163] "tail" "tan" "tanh"
[166] "to_physical" "to_r" "to_series"
[169] "to_struct" "top_k" "unique"
[172] "unique_counts" "upper_bound" "value_counts"
[175] "var" "when" "xor"

---

Expand Down Expand Up @@ -581,25 +580,24 @@
[115] "pct_change" "peak_max" "peak_min"
[118] "pow" "print" "product"
[121] "quantile" "rank" "rechunk"
[124] "reinterpret" "rep" "rep_extend"
[127] "repeat_by" "replace" "reshape"
[130] "reverse" "rle" "rle_id"
[133] "rolling" "rolling_max" "rolling_mean"
[136] "rolling_median" "rolling_min" "rolling_quantile"
[139] "rolling_skew" "rolling_std" "rolling_sum"
[142] "rolling_var" "round" "sample"
[145] "search_sorted" "set_sorted" "shift"
[148] "shift_and_fill" "shrink_dtype" "shuffle"
[151] "sign" "sin" "sinh"
[154] "skew" "slice" "sort"
[157] "sort_by" "sqrt" "std"
[160] "str" "struct" "sub"
[163] "sum" "tail" "tan"
[166] "tanh" "to_physical" "to_r"
[169] "to_series" "to_struct" "top_k"
[172] "unique" "unique_counts" "upper_bound"
[175] "value_counts" "var" "when"
[178] "xor"
[124] "reinterpret" "rep" "repeat_by"
[127] "replace" "reshape" "reverse"
[130] "rle" "rle_id" "rolling"
[133] "rolling_max" "rolling_mean" "rolling_median"
[136] "rolling_min" "rolling_quantile" "rolling_skew"
[139] "rolling_std" "rolling_sum" "rolling_var"
[142] "round" "sample" "search_sorted"
[145] "set_sorted" "shift" "shift_and_fill"
[148] "shrink_dtype" "shuffle" "sign"
[151] "sin" "sinh" "skew"
[154] "slice" "sort" "sort_by"
[157] "sqrt" "std" "str"
[160] "struct" "sub" "sum"
[163] "tail" "tan" "tanh"
[166] "to_physical" "to_r" "to_series"
[169] "to_struct" "top_k" "unique"
[172] "unique_counts" "upper_bound" "value_counts"
[175] "var" "when" "xor"

---

Expand Down Expand Up @@ -671,25 +669,25 @@
[121] "peak_max" "peak_min" "pow"
[124] "print" "product" "quantile"
[127] "rank" "rechunk" "reinterpret"
[130] "rename" "rep" "rep_extend"
[133] "repeat_by" "replace" "reshape"
[136] "reverse" "rle" "rle_id"
[139] "rolling_max" "rolling_mean" "rolling_median"
[142] "rolling_min" "rolling_quantile" "rolling_skew"
[145] "rolling_std" "rolling_sum" "rolling_var"
[148] "round" "sample" "search_sorted"
[151] "set_sorted" "shape" "shift"
[154] "shift_and_fill" "shrink_dtype" "shuffle"
[157] "sign" "sin" "sinh"
[160] "skew" "slice" "sort"
[163] "sort_by" "sqrt" "std"
[166] "str" "struct" "sub"
[169] "sum" "tail" "tan"
[172] "tanh" "to_frame" "to_list"
[175] "to_lit" "to_physical" "to_r"
[178] "to_struct" "to_vector" "top_k"
[181] "unique" "unique_counts" "upper_bound"
[184] "value_counts" "var" "xor"
[130] "rename" "rep" "repeat_by"
[133] "replace" "reshape" "reverse"
[136] "rle" "rle_id" "rolling_max"
[139] "rolling_mean" "rolling_median" "rolling_min"
[142] "rolling_quantile" "rolling_skew" "rolling_std"
[145] "rolling_sum" "rolling_var" "round"
[148] "sample" "search_sorted" "set_sorted"
[151] "shape" "shift" "shift_and_fill"
[154] "shrink_dtype" "shuffle" "sign"
[157] "sin" "sinh" "skew"
[160] "slice" "sort" "sort_by"
[163] "sqrt" "std" "str"
[166] "struct" "sub" "sum"
[169] "tail" "tan" "tanh"
[172] "to_frame" "to_list" "to_lit"
[175] "to_physical" "to_r" "to_struct"
[178] "to_vector" "top_k" "unique"
[181] "unique_counts" "upper_bound" "value_counts"
[184] "var" "xor"

---

Expand Down
20 changes: 0 additions & 20 deletions tests/testthat/test-expr_expr.R
Original file line number Diff line number Diff line change
Expand Up @@ -2177,26 +2177,6 @@ test_that("rep", {
expect_grepl_error(pl$lit(1:4)$rep(Inf))
})

test_that("rep_extend", {
expect_identical(pl$lit(1:4)$rep_extend(2:1, 2)$to_r(), c(1:4, 2:1, 2:1))
expect_identical(
pl$lit(1:4)$rep_extend(
pl$lit(c(2, 1))$cast(pl$dtypes$Int32),
2
)$to_r(),
c(1:4, 2:1, 2:1)
)
expect_identical(
pl$lit(1:4)$rep_extend(
pl$lit(c(2, 1)),
2
)$to_r(),
c(1:4, 2:1, 2:1) * 1.0
)
expect_identical(pl$lit(1)$rep_extend(numeric(), 5)$to_r(), 1)
expect_grepl_error(pl$lit(1)$rep_extend(1, -1))
expect_grepl_error(pl$lit(1)$rep_extend(1, Inf))
})

test_that("to_r", {
# objects with homomorphic translation between r and polars
Expand Down
Loading