Skip to content

Commit

Permalink
feat: add a new argument strict to pl$Series()
Browse files Browse the repository at this point in the history
  • Loading branch information
eitsupi committed May 3, 2024
1 parent dfdd62d commit fd18c57
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
7 changes: 6 additions & 1 deletion R/series__series.R
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,10 @@ Series_struct = method_as_active_binding(
#' If not `NULL`, that data type is used to [cast][Expr_cast] the Series created from the vector
#' to a specific data type internally.
#' @param ... Ignored.
#' @param strict A logical. If `TRUE` (default), throw an error if any value does not exactly match
#' the given data type by the `dtype` argument. If `FALSE`, values that do not match the data type
#' are cast to that data type or, if casting is not possible, set to `null` instead.
#' Passed to the `strict` argument of the [`$cast()`][Expr_cast] method internally.
#' @param nan_to_null If `TRUE`, `NaN` values contained in the Series are replaced to `null`.
#' Using the [`$fill_nan()`][Expr_fill_nan] method internally.
#' @return [Series][Series_class]
Expand All @@ -316,6 +320,7 @@ pl_Series = function(
values = NULL,
dtype = NULL,
...,
strict = TRUE,
nan_to_null = FALSE) {
uw = function(x) unwrap(x, "in pl$Series():")

Expand All @@ -328,7 +333,7 @@ pl_Series = function(
uw()

if (!is.null(dtype)) {
out = result(out$cast(dtype)) |>
out = result(out$cast(dtype, strict)) |>
uw()
}

Expand Down
14 changes: 13 additions & 1 deletion man/pl_Series.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit fd18c57

Please sign in to comment.