Skip to content

Commit 799df38

Browse files
author
Crunch.io Jenkins Account
committed
Merge remote-tracking branch 'origin/rel-6.5.2440'
2 parents 9e4cc5a + b81a53d commit 799df38

18 files changed

+120
-80
lines changed

.lintr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
linters: with_defaults(line_length_linter(100), commented_code_linter = NULL, closed_curly_linter = NULL, object_name_linter = NULL, commas_linter = NULL, spaces_left_parentheses_linter = NULL, cyclocomp_linter(complexity_limit = 16))
2-
exclusions: list("tests/testthat/helper-contexts.R", "tests/testthat/helper-expectations.R", "inst/crunch-test.R", "R/SO-survey.R")
1+
linters: linters_with_defaults(line_length_linter(100), commented_code_linter = NULL, brace_linter = NULL, object_name_linter = NULL, commas_linter = NULL, spaces_left_parentheses_linter = NULL, cyclocomp_linter(complexity_limit = 16), indentation_linter = NULL, infix_spaces_linter = NULL, T_and_F_symbol_linter = NULL, object_usage_linter = NULL, vector_logic_linter = NULL, paren_body_linter= NULL, quotes_linter = NULL)
2+
exclusions: list("tests/testthat/helper-contexts.R", "tests/testthat/helper-expectations.R", "inst/crunch-test.R", "R/SO-survey.R", "vignettes/")

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ install-ci: deps
1919
R -e 'devtools::session_info(installed.packages()[, "Package"])'
2020

2121
test-ci: compress-fixtures |
22-
R --slave -e 'library(covr); install_dir <- tempfile(); to_cobertura(package_coverage(quiet=FALSE, install_path=install_dir, clean=FALSE)); for (file in list.files(install_dir, pattern = "\\.Rout(\\.fail)?$$", recursive=TRUE, full.names=TRUE)) { cat(readLines(file), sep = "\n"); cat("\n") }'
22+
R --slave -e 'library(covr); install_dir <- tempfile(); test_run <- try(to_cobertura(package_coverage(quiet=FALSE, install_path=install_dir, clean=FALSE))); for (file in list.files(install_dir, pattern = "\\.Rout(\\.fail)?$$", recursive=TRUE, full.names=TRUE)) { cat(readLines(file), sep = "\n"); cat("\n") }; if (inherits(test_run, "try-error")) stop("Test failed!\n", attr(test_run, "condition")[["message"]], "\n", format(attr(test_run, "condition")[["call"]]))'
2323

2424
clean:
2525
R --slave -e 'library(crunch); set_crunch_opts(crunch.api=envOrOption("test.api"), crunch.api.key=envOrOption("crunch.test.api.key")); lapply(urls(datasets()), crDELETE)'

R/AllGenerics.R

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,4 +493,7 @@ fortify.CrunchDataFrame <- function(model, data, ...) model
493493
#' @export fortify.CrunchDataset
494494
fortify.CrunchDataset <- function(model, data, ...) model
495495

496-
setGeneric("sendCrunchAutomationScript", function(x, ...) standardGeneric("sendCrunchAutomationScript"))
496+
setGeneric(
497+
"sendCrunchAutomationScript",
498+
function(x, ...) standardGeneric("sendCrunchAutomationScript")
499+
)

R/api.R

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,10 @@ handleAPIfailure <- function(code, response) {
223223
# but we adapt to those on a case-by-case basis, like crunchAutomationErrorHandler)
224224
if (is.character(err_content$message) && length(err_content$message) == 1) {
225225
msg2 <- err_content$message
226-
} else if (is.character(err_content$description) && length(err_content$description) == 1) {
226+
} else if (
227+
is.character(err_content$description) &&
228+
length(err_content$description) == 1
229+
) {
227230
msg2 <- err_content$description
228231
}
229232
}

R/automation.R

Lines changed: 36 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -197,39 +197,45 @@ setMethod("sendCrunchAutomationScript", "CrunchDataset", function(x,
197197
invisible(NULL)
198198
})
199199

200-
setMethod("sendCrunchAutomationScript", "ProjectFolder", function(x,
201-
script,
202-
is_file = string_is_file_like(script),
203-
encoding = "UTF-8",
204-
...) {
205-
# project folders include a slot views with element execute,
206-
# which gives us the URL to hit;
207-
# but the account ('top-level folder', what you get from: `projects()`)
208-
# is also of class ProjectFolder, but doesn't include this info;
209-
# running CA scripts on the account is not supported currently
210-
if (!is.crunchURL(x@views$execute)) {
211-
halt(
212-
"This folder does not support Crunch Automation scripts at this time."
213-
)
214-
}
200+
setMethod(
201+
"sendCrunchAutomationScript",
202+
"ProjectFolder",
203+
function(
204+
x,
205+
script,
206+
is_file = string_is_file_like(script),
207+
encoding = "UTF-8",
208+
...
209+
) {
210+
# project folders include a slot views with element execute,
211+
# which gives us the URL to hit;
212+
# but the account ('top-level folder', what you get from: `projects()`)
213+
# is also of class ProjectFolder, but doesn't include this info;
214+
# running CA scripts on the account is not supported currently
215+
if (!is.crunchURL(x@views$execute)) {
216+
halt(
217+
"This folder does not support Crunch Automation scripts at this time."
218+
)
219+
}
215220

216-
dots <- list(...)
217-
if (length(dots) > 0) {
218-
# could have been a warning, but went with error in case a user
219-
# would try running a destructive operation with dry_run = TRUE
220-
stop("extra arguments (...) are not supported when x is a ProjectFolder")
221-
}
221+
dots <- list(...)
222+
if (length(dots) > 0) {
223+
# could have been a warning, but went with error in case a user
224+
# would try running a destructive operation with dry_run = TRUE
225+
stop("extra arguments (...) are not supported when x is a ProjectFolder")
226+
}
222227

223-
crPOST(
224-
shojiURL(x, "views", "execute"),
225-
body = toJSON(wrapView(value = script)),
226-
status.handlers = list(`400` = crunchAutomationErrorHandler),
227-
progress.handler = crunchAutomationErrorHandler,
228-
config = add_headers(`Content-Type` = "application/json")
229-
)
228+
crPOST(
229+
shojiURL(x, "views", "execute"),
230+
body = toJSON(wrapView(value = script)),
231+
status.handlers = list(`400` = crunchAutomationErrorHandler),
232+
progress.handler = crunchAutomationErrorHandler,
233+
config = add_headers(`Content-Type` = "application/json")
234+
)
230235

231-
invisible(NULL)
232-
})
236+
invisible(NULL)
237+
}
238+
)
233239

234240
string_is_file_like <- function(x) {
235241
length(x) == 1 && # length 1 string

R/hide-variables.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
#' - `hide()` / `privatize()` - take a `CrunchVariable` or `VariableCatalog` and
1616
#' make them hidden/private. (`unhide()` / `deprivatize()` put them back in the main
1717
#' variable catalog).
18-
#' - `hiddenFolder()` / `privateFolder()` / `publicFolder()` - take a dataset and return a folder that
19-
#' contains the public/hidden/private variables. This folder is like other `CrunchFolder`s and
20-
#' so you can use [`mkdir()`] to create subfolders and [`mv()`] to move them in/out.
18+
#' - `hiddenFolder()` / `privateFolder()` / `publicFolder()` - take a dataset and return a folder
19+
#' that contains the public/hidden/private variables. This folder is like other `CrunchFolder`s
20+
#' and so you can use [`mkdir()`] to create subfolders and [`mv()`] to move them in/out.
2121
#' - `hiddenVariables()` / `privateVariabiles()` - return a character vector of variables
2222
#' that are hidden/private. You can assign into the catalog to add variables or
2323
#' assign to `NULL` to remove all of them.
@@ -146,4 +146,4 @@ hiddenVariables <- function(dataset, key = namekey(dataset)) {
146146
} else {
147147
return(c())
148148
}
149-
}
149+
}

data-raw/SO-survey.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
stack_df <- read.csv("data-raw/survey_results_public.csv") ## This file is big and not checked into git
1+
## This file is big and not checked into git
2+
stack_df <- read.csv("data-raw/survey_results_public.csv")
23

34
r_users <- grep("R;|R$", stack_df$HaveWorkedLanguage)
45
keepvars <- c(

tests/testthat/setup.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ decompress_fixtures()
2121
set_crunch_opts(
2222
"old.crunch.api" = crunch:::get_crunch_opt("crunch.api"),
2323
"crunch.api" = "https://app.crunch.io/api/"
24-
)
24+
)

tests/testthat/test-append-debug.R

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,15 @@ with_test_authentication({
7373
ds1 <- refresh(ds1)
7474
ds1$comb <- combine(ds1$petloc,
7575
name = "Comb 1",
76-
combinations = list(list(name = "Mammals", categories = c("Cat", "Dog")))
76+
combinations = list(
77+
list(name = "Mammals", categories = c("Cat", "Dog"))
78+
)
7779
)
7880
ds1$comb2 <- combine(ds1$petloc,
7981
name = "Comb 2",
80-
combinations = list(list(name = "Mammals", categories = c("Cat", "Dog")))
82+
combinations = list(
83+
list(name = "Mammals", categories = c("Cat", "Dog"))
84+
)
8185
)
8286
test_that("The array has one fewer subvars in ds1", {
8387
expect_identical(aliases(subvariables(ds1$petloc)), "petloc_home")

tests/testthat/test-automation.R

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ with_mock_crunch({
4848
expect_POST(
4949
fixed = TRUE,
5050
suppressWarnings(
51-
runCrunchAutomation(dataset = ds, script_text, foo = 1, bar = 2)
51+
runCrunchAutomation(dataset = ds, script_text, foo = 1, bar = 2)
5252
),
5353
"https://app.crunch.io/api/datasets/1/scripts/",
5454
'{"element":"shoji:entity",',
@@ -281,12 +281,12 @@ with_mock_crunch({
281281
expected
282282
)
283283
})
284-
284+
285285
test_that("folder-level operation fails on root", {
286-
286+
287287
root_project_folder <- projects()
288288
script <- "CREATE FOLDER 'My not-to-be folder';"
289-
289+
290290
expect_error(
291291
runCrunchAutomation(root_project_folder, script),
292292
"not support Crunch Automation scripts"
@@ -309,17 +309,17 @@ with_mock_crunch({
309309
fixed = TRUE
310310
)
311311
})
312-
312+
313313
test_that("extra arguments result in an error for folder-level operations", {
314-
314+
315315
project_folder <- cd(projects(), 'Project One')
316316
script <- "CREATE FOLDER 'My to-be folder';"
317317
expected_url <- "https://app.crunch.io/api/projects/project1/execute/"
318318
expected_body <- paste0(
319319
'{"element":"shoji:view",',
320320
paste0('"value":', '"', script, '"'), '}'
321321
)
322-
322+
323323
expect_error(
324324
expect_POST(
325325
runCrunchAutomation(project_folder, script, foo = 1, bar = '2'),

tests/testthat/test-cube-subset.R

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,10 @@ if (tolower(Sys.info()[["sysname"]]) != "windows") {
102102
)
103103
)
104104
)
105-
expect_identical(subsetArrayDimension(cat_x_mr_x_mr@dims[[1]], 1:2, "categorical"), expected)
105+
expect_identical(
106+
subsetArrayDimension(cat_x_mr_x_mr@dims[[1]], 1:2, "categorical"),
107+
expected
108+
)
106109
})
107110

108111
test_that("subsetArrayDimension MR dimension", {
@@ -285,9 +288,15 @@ if (tolower(Sys.info()[["sysname"]]) != "windows") {
285288
expect_equal(as.array(subset_cat_x_mr_x_mr), as.array(cat_x_mr_x_mr)[1:2, , ])
286289

287290
subset_cat_x_mr_x_mr_withNA <- cat_x_mr_x_mr_withNA[c(1, 3), , ]
288-
expect_equal(as.array(subset_cat_x_mr_x_mr_withNA), as.array(cat_x_mr_x_mr_withNA)[c(1, 3), , ])
291+
expect_equal(
292+
as.array(subset_cat_x_mr_x_mr_withNA),
293+
as.array(cat_x_mr_x_mr_withNA)[c(1, 3), , ]
294+
)
289295
subset_cat_x_mr_x_mr_withNA <- cat_x_mr_x_mr_withNA[c(1, 2), , ]
290-
expect_equal(as.array(subset_cat_x_mr_x_mr_withNA), as.array(cat_x_mr_x_mr_withNA)[c(1, 2), , ])
296+
expect_equal(
297+
as.array(subset_cat_x_mr_x_mr_withNA),
298+
as.array(cat_x_mr_x_mr_withNA)[c(1, 2), , ]
299+
)
291300

292301
# subset cols
293302
# drop the No Data row which is #2 here!
@@ -298,9 +307,15 @@ if (tolower(Sys.info()[["sysname"]]) != "windows") {
298307
expect_equal(as.array(subset_cat_x_mr_x_mr), as.array(cat_x_mr_x_mr)[, c(1, 3), ])
299308

300309
subset_cat_x_mr_x_mr_withNA <- cat_x_mr_x_mr_withNA[, c(1, 3), ]
301-
expect_equal(as.array(subset_cat_x_mr_x_mr_withNA), as.array(cat_x_mr_x_mr_withNA)[, c(1, 3), ])
310+
expect_equal(
311+
as.array(subset_cat_x_mr_x_mr_withNA),
312+
as.array(cat_x_mr_x_mr_withNA)[, c(1, 3), ]
313+
)
302314
subset_cat_x_mr_x_mr_withNA <- cat_x_mr_x_mr_withNA[, c(1, 2), ]
303-
expect_equal(as.array(subset_cat_x_mr_x_mr_withNA), as.array(cat_x_mr_x_mr_withNA)[, c(1, 2), ])
315+
expect_equal(
316+
as.array(subset_cat_x_mr_x_mr_withNA),
317+
as.array(cat_x_mr_x_mr_withNA)[, c(1, 2), ]
318+
)
304319

305320
# subset cols with drop
306321
subset_cat_x_mr_x_mr <- cat_x_mr_x_mr[, 3, ]

tests/testthat/test-cube-transforms.R

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,7 @@ if (tolower(Sys.info()[["sysname"]]) != "windows") {
696696
)
697697

698698
# malform the transform for animals only
699-
pet_feeling_bad_feelings@dims$feelings$references$view$transform$insertions[[2]]$anchor <- NA
699+
pet_feeling_bad_feelings@dims$feelings$references$view$transform$insertions[[2]]$anchor <- NA # nolint
700700
expect_warning(
701701
expect_equivalent(applyTransforms(pet_feeling_bad_feelings), only_feelings),
702702
"Transforms for dimensions 1 were malformed and have been ignored."
@@ -815,8 +815,8 @@ if (tolower(Sys.info()[["sysname"]]) != "windows") {
815815
all <- cubify(
816816
7.09439811221956, 29.943091432266, 26.594536972556, 104.244359622909, 235.256710642724,
817817
28.3930651341193, 99.907133775628, 121.487888771867, 399.597650747672, 626.93247871747,
818-
16.4723263871271, 41.5273628588211, 58.5641962784524, 183.864543659439, 234.846288302351,
819-
4.82634063477261, 28.4366794845409, 36.3291555208591, 111.488747465324, 156.829479772395,
818+
16.4723263871271, 41.5273628588211, 58.5641962784524, 183.864543659439, 234.846288302351, # nolint
819+
4.82634063477261, 28.4366794845409, 36.3291555208591, 111.488747465324, 156.829479772395, # nolint
820820
12.217223612475, 42.1476791820657, 89.3309048228944, 218.631137785724, 171.129707467715,
821821
12.217223612475, 42.1476791820657, 89.3309048228944, 218.631137785724, 171.129707467715,
822822
dims = cat_mr_dims_subtotals
@@ -832,12 +832,12 @@ if (tolower(Sys.info()[["sysname"]]) != "windows") {
832832

833833
test_that("cat by mr, with cat subtotals (margins and proportions)", {
834834
row_margin <- cubify(
835-
51.911366492838, 69.0306061146165, 70.6657653721693, 142.042366487671, 253.602877279968,
836-
197.750644752234, 263.820951392254, 276.216370215392, 509.242733468184, 726.557193538396,
837-
93.7790931477866, 121.118408249056, 130.06549190286, 231.730645711963, 279.991871527124,
838-
52.0601851116097, 73.6719370285819, 75.4851129403625, 135.46972126855, 192.962444731304,
839-
70.2849657255216, 94.3678915294494, 135.475226421184, 251.200447977195, 215.124923979429,
840-
70.2849657255216, 94.3678915294494, 135.475226421184, 251.200447977195, 215.124923979429,
835+
51.911366492838, 69.0306061146165, 70.6657653721693, 142.042366487671, 253.602877279968, # nolint
836+
197.750644752234, 263.820951392254, 276.216370215392, 509.242733468184, 726.557193538396, # nolint
837+
93.7790931477866, 121.118408249056, 130.06549190286, 231.730645711963, 279.991871527124, # nolint
838+
52.0601851116097, 73.6719370285819, 75.4851129403625, 135.46972126855, 192.962444731304, # nolint
839+
70.2849657255216, 94.3678915294494, 135.475226421184, 251.200447977195, 215.124923979429, # nolint
840+
70.2849657255216, 94.3678915294494, 135.475226421184, 251.200447977195, 215.124923979429, # nolint
841841
dims = cat_mr_dims_subtotals
842842
)
843843
expect_equivalent(as.array(margin.table(cat_mr, 1)), row_margin)

tests/testthat/test-expressions.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ if (tolower(Sys.info()[["sysname"]]) != "windows") {
220220
})
221221

222222
test_that("Show method for expresssions", {
223-
skip("TODO: something intelligent with parentheses and order of operations (GH issue #99)")
223+
skip("TODO: something smart with parentheses and order of operations (GH issue #99)")
224224
print(ds$birthyr * 3 + 5)
225225
print(3 * (ds$birthyr + 5))
226226
})
@@ -238,7 +238,7 @@ if (tolower(Sys.info()[["sysname"]]) != "windows") {
238238
unclass(toJSON(expr@expression)),
239239
paste0(
240240
'{"function":"difftime","args":[{"variable":"https://app.crunch.io/api/datasets/1/variables/starttime/"},', #nolint
241-
'{"variable":"https://app.crunch.io/api/datasets/1/variables/starttime/"},null]}'
241+
'{"variable":"https://app.crunch.io/api/datasets/1/variables/starttime/"},null]}' # nolint
242242
)
243243
)
244244

tests/testthat/test-folders.R

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,9 @@ if (tolower(Sys.info()[["sysname"]]) != "windows") {
259259
)
260260
## Duplicates are resolved
261261
expect_PATCH(
262-
ds %>% cd("Group 1") %>% mv(c(starts_with("Birth"), ends_with("Year")), "../Group 2"),
262+
ds %>%
263+
cd("Group 1") %>%
264+
mv(c(starts_with("Birth"), ends_with("Year")), "../Group 2"),
263265
add_birthyr_to_group2
264266
)
265267
expect_PATCH(

0 commit comments

Comments
 (0)