Skip to content

Commit

Permalink
Skip tests on windows & update version
Browse files Browse the repository at this point in the history
  • Loading branch information
gergness committed Jan 27, 2022
1 parent 467cc45 commit 2e04df8
Show file tree
Hide file tree
Showing 15 changed files with 6,521 additions and 6,487 deletions.
2 changes: 0 additions & 2 deletions CRAN-RELEASE

This file was deleted.

2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Description: The Crunch.io service <https://crunch.io/> provides a cloud-based
datasets from within R. Importantly, this allows technical researchers to
collaborate naturally with team members, managers, and clients who prefer a
point-and-click interface.
Version: 1.28.3
Version: 1.29.0
Authors@R: c(
person("Greg", "Freedman Ellis", role = c("aut", "cre"), email = "greg@crunch.io"),
person("Jonathan", "Keane", role="aut", email="jkeane@gmail.com"),
Expand Down
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# crunch 1.28.3
# crunch 1.29.0
* Authenticating with an API key is now the recommended way to use the R crunch package. See
the `vignette("crunch")` or `?crunch-api-key` for more details. The `login()` authentication
flow is deprecated and will be removed from an upcoming release.
Expand Down
116 changes: 60 additions & 56 deletions tests/testthat/test-cube-bases.R
Original file line number Diff line number Diff line change
@@ -1,69 +1,73 @@
context("'Base sizes' in cubes")

all.dims <- list(
Admit = c("Admitted", "Rejected"),
Gender = c("Male", "Female")
)
# Skip tests on windows (because they're slow and CRAN complains)
if (tolower(Sys.info()[["sysname"]]) != "windows") {

cube <- loadCube("cubes/admit-by-gender-weighted.json")
b <- cubify(
1198, 557,
1493, 1278,
dims = all.dims
)
test_that("'bases' can be accessed and all margins work", {
expect_identical(
round(cube),
cubify(
1170, 547,
1474, 1261,
dims = all.dims
)
all.dims <- list(
Admit = c("Admitted", "Rejected"),
Gender = c("Male", "Female")
)
expect_identical(bases(cube, 0), b)
expect_identical(bases(cube, 1), margin.table(b, 1))
expect_identical(bases(cube, 2), margin.table(b, 2))
expect_identical(bases(cube), sum(b))
})

with_mock_crunch({
ds <- cachedLoadDataset("test ds")
m <- multitables(ds)[[1]]
with_POST("https://app.crunch.io/api/datasets/1/multitables/apidocs-tabbook/", {
book1 <- tabBook(m, data = ds, output_format = "json")
})

test_that("bases methods exist for TabBookResult and MultitableResult", {
cube <- loadCube("cubes/admit-by-gender-weighted.json")
b <- cubify(
1198, 557,
1493, 1278,
dims = all.dims
)
test_that("'bases' can be accessed and all margins work", {
expect_identical(
bases(book1, 0)[[1]][[2]],
round(cube),
cubify(
4, 0, 1,
0, 5, 3,
1, 3, 5,
dims = list(
allpets = c("Cat", "Dog", "Bird"),
allpets = c("Cat", "Dog", "Bird")
)
1170, 547,
1474, 1261,
dims = all.dims
)
)
expect_identical(
bases(book1)[[1]][[2]],
cubify(
17,
dims = list(
allpets = c("Cat", "Dog", "Bird"),
allpets = c("Cat", "Dog", "Bird")
expect_identical(bases(cube, 0), b)
expect_identical(bases(cube, 1), margin.table(b, 1))
expect_identical(bases(cube, 2), margin.table(b, 2))
expect_identical(bases(cube), sum(b))
})

with_mock_crunch({
ds <- cachedLoadDataset("test ds")
m <- multitables(ds)[[1]]
with_POST("https://app.crunch.io/api/datasets/1/multitables/apidocs-tabbook/", {
book1 <- tabBook(m, data = ds, output_format = "json")
})

test_that("bases methods exist for TabBookResult and MultitableResult", {
expect_identical(
bases(book1, 0)[[1]][[2]],
cubify(
4, 0, 1,
0, 5, 3,
1, 3, 5,
dims = list(
allpets = c("Cat", "Dog", "Bird"),
allpets = c("Cat", "Dog", "Bird")
)
)
)
)
})
expect_identical(
bases(book1)[[1]][[2]],
cubify(
17,
dims = list(
allpets = c("Cat", "Dog", "Bird"),
allpets = c("Cat", "Dog", "Bird")
)
)
)
})

test_that("base for univariate stats", {
skip("Need to use `cube_valid_count` to calculate base size")
expect_equal(bases(crtabs(max(birthyr) ~ 1, data = ds)), 25)
expect_error(bases(crtabs(max(birthyr) ~ 1, data = ds), 1),
"Margin 1 exceeds Cube's number of dimensions (0)",
fixed = TRUE
)
test_that("base for univariate stats", {
skip("Need to use `cube_valid_count` to calculate base size")
expect_equal(bases(crtabs(max(birthyr) ~ 1, data = ds)), 25)
expect_error(bases(crtabs(max(birthyr) ~ 1, data = ds), 1),
"Margin 1 exceeds Cube's number of dimensions (0)",
fixed = TRUE
)
})
})
})
}
Loading

0 comments on commit 2e04df8

Please sign in to comment.