-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathtest_aggregates.R
More file actions
40 lines (32 loc) · 2.04 KB
/
Copy pathtest_aggregates.R
File metadata and controls
40 lines (32 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
library(tinytest)
library(tiledb)
if (tiledb_version(TRUE) < "2.18.0") exit_file("Needs TileDB 2.18.0 or later")
if (!requireNamespace("palmerpenguins", quietly=TRUE)) exit_file("Remainder needs 'palmerpenguins'")
tiledb_ctx(limitTileDBCores())
isRESTCI <- Sys.getenv("TILEDB_CLOUD_REST_BIN", "") != ""
if (isRESTCI) {
## we can rely on the normal tempfile semantics but override the tmpdir
## argument to be our REST CI base url in the unit test namespace
tempfile <- function() { base::tempfile(tmpdir="tiledb://unit") }
}
library(palmerpenguins)
uri <- tempfile()
expect_silent(fromDataFrame(penguins, uri, sparse=TRUE))
expect_silent(arr <- tiledb_array(uri, extended=FALSE))
if (Sys.getenv("CI", "") != "") { # error handler needs a correction so skipping until that is made
expect_error(tiledb_array_apply_aggregate(uri, "body_mass_g", "Mean")) # not an array
expect_error(tiledb_array_apply_aggregate(arr, "does_not_exit", "Mean")) # not an attribute
expect_error(tiledb_array_apply_aggregate(arr, "body_mass_g", "UnknownFunction")) # not an operator
}
expect_equal(tiledb_array_apply_aggregate(arr, "body_mass_g", "Count", FALSE), 344)
expect_equal(tiledb_array_apply_aggregate(arr, "body_mass_g", "NullCount"), 2)
expect_equal(tiledb_array_apply_aggregate(arr, "body_mass_g", "Min"), 2700)
expect_equal(tiledb_array_apply_aggregate(arr, "body_mass_g", "Max"), 6300)
expect_equal(tiledb_array_apply_aggregate(arr, "body_mass_g", "Sum"), 1437000)
expect_equal(tiledb_array_apply_aggregate(arr, "body_mass_g", "Mean"), 4201.7543869)
expect_equal(tiledb_array_apply_aggregate(arr, "year", "Count", FALSE), 344)
expect_error(tiledb_array_apply_aggregate(arr, "year", "NullCount")) # no nullcount on non-nullable
expect_equal(tiledb_array_apply_aggregate(arr, "year", "Min", FALSE), 2007)
expect_equal(tiledb_array_apply_aggregate(arr, "year", "Max", FALSE), 2009)
expect_equal(tiledb_array_apply_aggregate(arr, "year", "Sum", FALSE), 690762)
expect_equal(tiledb_array_apply_aggregate(arr, "year", "Mean", FALSE), 2008.02906977)