Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ Imports:
Suggests:
spelling,
testthat (>= 3.0.0)
RoxygenNote: 7.3.3
RoxygenNote: 8.0.0
Encoding: UTF-8
Language: en-GB
Config/testthat/edition: 3
2 changes: 1 addition & 1 deletion R/lengthDS.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#'
lengthDS <- function(x){
x.val <- .loadServersideObject(x)
.checkClass(obj = x.val, obj_name = x, permitted_classes = c("character", "factor", "integer", "logical", "numeric", "list", "data.frame"))
.checkClass(obj = x.val, obj_name = x, permitted_classes = c("character", "factor", "integer", "logical", "numeric", "list", "data.frame", "array", "matrix"))
list(length = length(x.val), class = class(x.val))
}
#AGGREGATE FUNCTION
Expand Down
5 changes: 2 additions & 3 deletions man/levelsDS.Rd

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

20 changes: 20 additions & 0 deletions tests/testthat/test-smk-lengthDS.R
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,26 @@ test_that("simple lengthDS, character data.frame", {
expect_equal(res$class, "data.frame")
})

test_that("simple lengthDS, matrix", {
input <- matrix(1:6, nrow = 2, ncol = 3)

res <- lengthDS("input")

expect_equal(class(res), "list")
expect_equal(res$length, 6)
expect_equal(res$class, c("matrix", "array"))
})

test_that("simple lengthDS, array", {
input <- array(1:24, dim = c(2, 3, 4))

res <- lengthDS("input")

expect_equal(class(res), "list")
expect_equal(res$length, 24)
expect_equal(res$class, "array")
})

#
# Done
#
Expand Down
9 changes: 9 additions & 0 deletions tests/testthat/test-smk-levelsDS.R
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@ test_that("levelsDS throws error when object is not a factor", {
)
})

test_that("levelsDS blocks when levels density exceeds threshold", {
input <- factor(1:10, levels = 1:10)

expect_error(
levelsDS("input"),
regexp = "nfilter.levels.density"
)
})

#
# Done
#
Expand Down
Loading