Skip to content

Commit

Permalink
refactor: rename flag internals
Browse files Browse the repository at this point in the history
  • Loading branch information
etiennebacher committed Jun 6, 2024
1 parent 706d1e9 commit 69c5155
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 29 deletions.
6 changes: 3 additions & 3 deletions R/extendr-wrappers.R
Original file line number Diff line number Diff line change
Expand Up @@ -1332,11 +1332,11 @@ RPolarsSeries$arg_min <- function() .Call(wrap__RPolarsSeries__arg_min, self)

RPolarsSeries$arg_max <- function() .Call(wrap__RPolarsSeries__arg_max, self)

RPolarsSeries$fast_explode_flag <- function() .Call(wrap__RPolarsSeries__fast_explode_flag, self)
RPolarsSeries$can_fast_explode_flag <- function() .Call(wrap__RPolarsSeries__can_fast_explode_flag, self)

RPolarsSeries$is_sorted_flag <- function() .Call(wrap__RPolarsSeries__is_sorted_flag, self)
RPolarsSeries$is_sorted_ascending_flag <- function() .Call(wrap__RPolarsSeries__is_sorted_ascending_flag, self)

RPolarsSeries$is_sorted_reverse_flag <- function() .Call(wrap__RPolarsSeries__is_sorted_reverse_flag, self)
RPolarsSeries$is_sorted_descending_flag <- function() .Call(wrap__RPolarsSeries__is_sorted_descending_flag, self)

RPolarsSeries$is_sorted <- function(descending) .Call(wrap__RPolarsSeries__is_sorted, self, descending)

Expand Down
6 changes: 3 additions & 3 deletions R/series__series.R
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,14 @@ Series_dtype = method_as_active_binding(\() .pr$Series$dtype(self))
Series_flags = method_as_active_binding(
\() {
out = list(
"SORTED_ASC" = .pr$Series$is_sorted_flag(self),
"SORTED_DESC" = .pr$Series$is_sorted_reverse_flag(self)
"SORTED_ASC" = .pr$Series$is_sorted_ascending_flag(self),
"SORTED_DESC" = .pr$Series$is_sorted_descending_flag(self)
)

# the width value given here doesn't matter, but pl$Array() must have one
if (pl$same_outer_dt(self$dtype, pl$List()) ||
pl$same_outer_dt(self$dtype, pl$Array(width = 1))) {
out[["FAST_EXPLODE"]] = .pr$Series$fast_explode_flag(self)
out[["FAST_EXPLODE"]] = .pr$Series$can_fast_explode_flag(self)
}

out
Expand Down
9 changes: 3 additions & 6 deletions src/rust/src/series.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,21 +181,18 @@ impl RPolarsSeries {
self.0.arg_max()
}

// TODO: rename to `can_fast_explode_flag`
pub fn fast_explode_flag(&self) -> bool {
pub fn can_fast_explode_flag(&self) -> bool {
match self.0.list() {
Err(_) => false,
Ok(list) => list._can_fast_explode(),
}
}

// TODO: rename to `is_sorted_ascending_flag`
pub fn is_sorted_flag(&self) -> bool {
pub fn is_sorted_ascending_flag(&self) -> bool {
matches!(self.0.is_sorted_flag(), IsSorted::Ascending)
}

// TODO: rename to `is_sorted_descending_flag`
pub fn is_sorted_reverse_flag(&self) -> bool {
pub fn is_sorted_descending_flag(&self) -> bool {
matches!(self.0.is_sorted_flag(), IsSorted::Descending)
}

Expand Down
43 changes: 26 additions & 17 deletions tests/testthat/_snaps/after-wrappers.md
Original file line number Diff line number Diff line change
Expand Up @@ -721,23 +721,32 @@
Code
ls(.pr[[private_key]])
Output
[1] "add" "alias" "all"
[4] "any" "append_mut" "arg_max"
[7] "arg_min" "chunk_lengths" "clear"
[10] "clone" "compare" "div"
[13] "dtype" "equals" "export_stream"
[16] "fast_explode_flag" "from_arrow_array_robj" "get_fmt"
[19] "import_stream" "is_sorted" "is_sorted_flag"
[22] "is_sorted_reverse_flag" "len" "map_elements"
[25] "max" "mean" "median"
[28] "min" "mul" "n_chunks"
[31] "n_unique" "name" "new"
[34] "panic" "print" "rem"
[37] "rename_mut" "rep" "set_sorted_mut"
[40] "shape" "sleep" "sort"
[43] "std" "struct_fields" "sub"
[46] "sum" "to_fmt_char" "to_frame"
[49] "to_r" "value_counts" "var"
[1] "add" "alias"
[3] "all" "any"
[5] "append_mut" "arg_max"
[7] "arg_min" "can_fast_explode_flag"
[9] "chunk_lengths" "clear"
[11] "clone" "compare"
[13] "div" "dtype"
[15] "equals" "export_stream"
[17] "from_arrow_array_robj" "get_fmt"
[19] "import_stream" "is_sorted"
[21] "is_sorted_ascending_flag" "is_sorted_descending_flag"
[23] "len" "map_elements"
[25] "max" "mean"
[27] "median" "min"
[29] "mul" "n_chunks"
[31] "n_unique" "name"
[33] "new" "panic"
[35] "print" "rem"
[37] "rename_mut" "rep"
[39] "set_sorted_mut" "shape"
[41] "sleep" "sort"
[43] "std" "struct_fields"
[45] "sub" "sum"
[47] "to_fmt_char" "to_frame"
[49] "to_r" "value_counts"
[51] "var"

# public and private methods of each class RThreadHandle

Expand Down

0 comments on commit 69c5155

Please sign in to comment.