-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add remaining subnamespaces for
Series
(#828)
- Loading branch information
1 parent
ff1bd11
commit f3a71df
Showing
7 changed files
with
144 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,52 @@ | ||
test_that("Series to lower case", { | ||
test_that("string sub namespace", { | ||
expect_identical( | ||
pl$Series(c("A", "B", NA, "D"))$str$to_lowercase()$to_r(), | ||
c("a", "b", NA, "d") | ||
) | ||
}) | ||
|
||
test_that("Series to upper case", { | ||
test_that("List sub namespace", { | ||
expect_identical( | ||
pl$Series(c("a", "b", NA, "d"))$str$to_uppercase()$to_r(), | ||
c("A", "B", NA, "D") | ||
pl$Series(list(3:1, 1:2, NULL))$list$first()$to_r(), | ||
c(3L, 1L, NA) | ||
) | ||
}) | ||
|
||
test_that("List sub namespace", { | ||
test_that("datetime sub namespace", { | ||
s = pl$date_range( | ||
as.Date("2024-02-18"), as.Date("2024-02-24"), | ||
interval = "1d" | ||
)$to_series() | ||
|
||
expect_identical( | ||
pl$Series(list(3:1, 1:2, NULL))$list$first()$to_r(), | ||
c(3L, 1L, NA) | ||
s$dt$day()$to_r(), | ||
18:24 | ||
) | ||
}) | ||
|
||
test_that("binary subnamespace", { | ||
s = pl$Series(c(r"(\x00\x00\x00)", r"(\xff\xff\x00)", r"(\x00\x00\xff)"))$ | ||
to_lit()$ | ||
cast(pl$Binary)$ | ||
to_series() | ||
expect_identical( | ||
s$bin$contains(pl$lit(r"(\xff)")$cast(pl$Binary))$to_r(), | ||
c(FALSE, TRUE, TRUE) | ||
) | ||
}) | ||
|
||
test_that("categorical sub namespace", { | ||
s = pl$Series(factor(c("foo", "bar", "foo", "foo", "ham"))) | ||
expect_identical( | ||
s$cat$get_categories()$to_r(), | ||
c("foo", "bar", "ham") | ||
) | ||
}) | ||
|
||
# TODO: this panicks | ||
# test_that("array sub namespace", { | ||
# s = pl$Series(list(3:1, 1:2, c(NA_integer_, 4L)))$ | ||
# to_lit()$ | ||
# cast(pl$Array(width = 2))$ | ||
# to_series() | ||
# }) |