Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

data.table Depends -> Imports #246

Merged
merged 2 commits into from
Sep 21, 2019
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@
/vignettes/*.pdf
/.Rproj.user
/batchtools.Rproj
*.tar.gz
*.Rcheck

4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ NeedsCompilation: yes
ByteCompile: yes
Encoding: UTF-8
Depends:
R (>= 3.0.0),
data.table (>= 1.11.2)
R (>= 3.0.0)
Imports:
backports (>= 1.1.2),
base64url (>= 1.1),
brew,
checkmate (>= 1.8.5),
data.table (>= 1.11.2),
digest (>= 0.6.9),
fs (>= 1.2.0),
parallel,
Expand Down
18 changes: 17 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,29 @@ export(ujoin)
export(unwrap)
export(waitForJobs)
import(checkmate)
import(data.table)
import(stringi)
import(utils)
importFrom(R6,R6Class)
importFrom(base64url,base32_decode)
importFrom(base64url,base32_encode)
importFrom(brew,brew)
importFrom(data.table,"%chin%")
importFrom(data.table,CJ)
importFrom(data.table,alloc.col)
importFrom(data.table,as.data.table)
importFrom(data.table,chmatch)
importFrom(data.table,copy)
importFrom(data.table,data.table)
importFrom(data.table,is.data.table)
importFrom(data.table,key)
importFrom(data.table,rbindlist)
importFrom(data.table,set)
importFrom(data.table,setattr)
importFrom(data.table,setkey)
importFrom(data.table,setkeyv)
importFrom(data.table,setnames)
importFrom(data.table,setorderv)
importFrom(data.table,uniqueN)
importFrom(digest,digest)
importFrom(progress,progress_bar)
importFrom(rappdirs,site_config_dir)
Expand Down
2 changes: 1 addition & 1 deletion R/ExperimentRegistry.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#' fun = function(job, data, n, mean, sd, ...) rnorm(n, mean = mean, sd = sd))
#' addAlgorithm(reg = tmp, "a1", fun = function(job, data, instance, ...) mean(instance))
#' addAlgorithm(reg = tmp, "a2", fun = function(job, data, instance, ...) median(instance))
#' ids = addExperiments(reg = tmp, list(p1 = CJ(n = c(50, 100), mean = -2:2, sd = 1:4)))
#' ids = addExperiments(reg = tmp, list(p1 = data.table::CJ(n = c(50, 100), mean = -2:2, sd = 1:4)))
#'
#' # Overview over defined experiments:
#' tmp$problems
Expand Down
1 change: 1 addition & 0 deletions R/addExperiments.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
#' addAlgorithm("deviation", fun = fun, reg = tmp)
#'
#' # define problem and algorithm designs
#' library(data.table)
#' prob.designs = algo.designs = list()
#' prob.designs$rnorm = CJ(n = 100, mean = -1:1, sd = 1:5)
#' prob.designs$rexp = data.table(n = 100, lambda = 1:5)
Expand Down
2 changes: 1 addition & 1 deletion R/batchMap.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
#'
#' # example for an expand.grid()-like operation on parameters
#' tmp = makeRegistry(file.dir = NA, make.default = FALSE)
#' ids = batchMap(paste, args = CJ(x = letters[1:3], y = 1:3), reg = tmp)
#' ids = batchMap(paste, args = data.table::CJ(x = letters[1:3], y = 1:3), reg = tmp)
#' getJobPars(reg = tmp)
#' testJob(6, reg = tmp)
batchMap = function(fun, ..., args = list(), more.args = list(), reg = getDefaultRegistry()) {
Expand Down
1 change: 1 addition & 0 deletions R/chunkIds.R
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
#' ids = batchMap(identity, 1:25, reg = tmp)
#'
#' ### Group into chunks with 10 jobs each
#' library(data.table)
#' ids[, chunk := chunk(job.id, chunk.size = 10)]
#' print(ids[, .N, by = chunk])
#'
Expand Down
5 changes: 3 additions & 2 deletions R/estimateRuntimes.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,15 @@
#' addProblem(name = "iris", data = iris, fun = function(data, ...) nrow(data), reg = tmp)
#' addAlgorithm(name = "nrow", function(instance, ...) nrow(instance), reg = tmp)
#' addAlgorithm(name = "ncol", function(instance, ...) ncol(instance), reg = tmp)
#' addExperiments(algo.designs = list(nrow = CJ(x = 1:50, y = letters[1:5])), reg = tmp)
#' addExperiments(algo.designs = list(ncol = CJ(x = 1:50, y = letters[1:5])), reg = tmp)
#' addExperiments(algo.designs = list(nrow = data.table::CJ(x = 1:50, y = letters[1:5])), reg = tmp)
#' addExperiments(algo.designs = list(ncol = data.table::CJ(x = 1:50, y = letters[1:5])), reg = tmp)
#'
#' # We use the job parameters to predict runtimes
#' tab = unwrap(getJobPars(reg = tmp))
#'
#' # First we need to submit some jobs so that the forest can train on some data.
#' # Thus, we just sample some jobs from the registry while grouping by factor variables.
#' library(data.table)
#' ids = tab[, .SD[sample(nrow(.SD), 5)], by = c("problem", "algorithm", "y")]
#' setkeyv(ids, "job.id")
#' submitJobs(ids, reg = tmp)
Expand Down
1 change: 1 addition & 0 deletions R/reduceResults.R
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ reduceResults = function(fun, ids = NULL, init, ..., reg = getDefaultRegistry())
#' addAlgorithm("deviation", fun = fun, reg = tmp)
#'
#' # define problem and algorithm designs
#' library(data.table)
#' prob.designs = algo.designs = list()
#' prob.designs$rnorm = CJ(n = 100, mean = -1:1, sd = 1:5)
#' prob.designs$rexp = data.table(n = 100, lambda = 1:5)
Expand Down
2 changes: 1 addition & 1 deletion R/submitJobs.R
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@
#' fun = function(n, p) colMeans(matrix(runif(n*p), n, p))
#'
#' # Arguments to fun:
#' args = CJ(n = c(1e4, 1e5), p = c(10, 50)) # like expand.grid()
#' args = data.table::CJ(n = c(1e4, 1e5), p = c(10, 50)) # like expand.grid()
#' print(args)
#'
#' # Map function to create jobs
Expand Down
2 changes: 1 addition & 1 deletion R/unwrap.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#' @return [\code{\link{data.table}}].
#' @export
#' @examples
#' x = data.table(
#' x = data.table::data.table(
#' id = 1:3,
#' values = list(list(a = 1, b = 3), list(a = 2, b = 2), list(a = 3))
#' )
Expand Down
5 changes: 4 additions & 1 deletion R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
#' loading \pkg{batchtools}.
#' @import utils
#' @import checkmate
#' @import data.table
#' @import stringi
#' @importFrom data.table %chin% alloc.col as.data.table data.table chmatch CJ copy data.table is.data.table key rbindlist set setattr setkey setkeyv setnames setorderv uniqueN
#' @importFrom R6 R6Class
#' @importFrom digest digest
#' @importFrom brew brew
Expand All @@ -31,6 +31,9 @@
#' @importFrom withr with_dir with_seed local_options local_dir
"_PACKAGE"

.BY = .N = .SD = NULL
`:=` = function(...) NULL

batchtools = new.env(parent = emptyenv())
batchtools$debug = FALSE
batchtools$hooks = list(
Expand Down
1 change: 1 addition & 0 deletions man/addExperiments.Rd

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

2 changes: 1 addition & 1 deletion man/batchMap.Rd

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

1 change: 1 addition & 0 deletions man/chunk.Rd

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

5 changes: 3 additions & 2 deletions man/estimateRuntimes.Rd

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

2 changes: 1 addition & 1 deletion man/makeExperimentRegistry.Rd

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

1 change: 1 addition & 0 deletions man/reduceResultsList.Rd

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

2 changes: 1 addition & 1 deletion man/submitJobs.Rd

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

2 changes: 1 addition & 1 deletion man/unwrap.Rd

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

2 changes: 1 addition & 1 deletion vignettes/batchtools.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ vignette: >

```{r,include = FALSE, cache = FALSE}
library(batchtools)
library(data.table) # for %chin%, data.table
options(batchtools.progress = FALSE, datatable.print.class = TRUE, batchtools.timestamps = FALSE)
if (identical(Sys.getenv("IN_PKGDOWN"), "true")) {
tmp_dir = fs::path(dirname(tempdir()), "batchtools-vignette")
Expand Down Expand Up @@ -527,4 +528,3 @@ This approach is totally viable as long as some general rules are followed:
6. Avoid accessing the `file.dir` with multiple sessions simultaneously.
This includes accessing the registry via a mount!
Simultaneous access may lead to inconsistencies and missing results.