Skip to content

Commit

Permalink
Update to new data.table (#999)
Browse files Browse the repository at this point in the history
  • Loading branch information
mllg authored Feb 22, 2024
1 parent 6abf415 commit 855bc2b
Show file tree
Hide file tree
Showing 15 changed files with 59 additions and 61 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Imports:
R6 (>= 2.4.1),
backports,
checkmate (>= 2.0.0),
data.table (>= 1.14.2),
data.table (>= 1.15.0),
evaluate,
future,
future.apply (>= 1.5.0),
Expand Down
2 changes: 1 addition & 1 deletion R/DataBackend.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
DataBackend = R6Class("DataBackend", cloneable = FALSE,
public = list(
#' @field primary_key (`character(1)`)\cr
#' Column name of the primary key column of unique integer row ids.
#' Column name of the primary key column of positive and unique integer row ids.
primary_key = NULL,

#' @field data_formats (`character()`)\cr
Expand Down
4 changes: 1 addition & 3 deletions R/DataBackendDataTable.R
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,7 @@ DataBackendDataTable = R6Class("DataBackendDataTable", inherit = DataBackend,
cols = intersect(cols, colnames(private$.data))

if (self$compact_seq) {
# https://github.com/Rdatatable/data.table/issues/3109
.__i__ = keep_in_bounds(rows, 1L, nrow(private$.data))
private$.data[.__i__, cols, with = FALSE]
private$.data[rows, cols, with = FALSE, nomatch = NULL]
} else {
ijoin(private$.data, rows, cols, self$primary_key)
}
Expand Down
2 changes: 1 addition & 1 deletion R/Task.R
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,7 @@ Task = R6Class("Task",
private$.hash
},

#' @field row_ids (`integer()`)\cr
#' @field row_ids (positive `integer()`)\cr
#' Returns the row ids of the [DataBackend] for observations with role "use".
row_ids = function(rhs) {
assert_ro_binding(rhs)
Expand Down
2 changes: 1 addition & 1 deletion R/as_data_backend.R
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ as_data_backend.data.frame = function(data, primary_key = NULL, keep_rownames =
if (is.character(primary_key)) {
assert_string(primary_key)
assert_choice(primary_key, colnames(data))
assert_integer(data[[primary_key]], any.missing = FALSE, unique = TRUE)
assert_integer(data[[primary_key]], any.missing = FALSE, unique = TRUE, lower = 0L)
} else {
if (is.null(primary_key)) {
row_ids = seq_row(data)
Expand Down
4 changes: 2 additions & 2 deletions inst/testthat/helper_expectations.R
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,12 @@ expect_backend = function(b) {
checkmate::expect_data_table(x, nrows = 0L, ncols = 0L)

# extra rows are ignored
query_rows = c(rn1, if (is.numeric(rn)) -1L else "_not_existing_")
query_rows = c(rn1, if (is.numeric(rn)) b$nrow + 1L else "_not_existing_")
x = b$data(query_rows, cols = cn[1L], data_format = "data.table")
checkmate::expect_data_table(x, nrows = length(rn1), ncols = 1L)

# zero rows matching
query_rows = if (is.numeric(rn)) -1L else "_not_existing_"
query_rows = if (is.numeric(rn)) b$nrow + 1L else "_not_existing_"
x = b$data(rows = query_rows, cols = cn[1L], data_format = "data.table")
checkmate::expect_data_table(x, nrows = 0L, ncols = 1L)

Expand Down
4 changes: 2 additions & 2 deletions man-roxygen/param_cols.R
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#' @param cols `character()`\cr
#' Column names.
#' @param cols (`character()`)\cr
#' Vector of column names.
4 changes: 2 additions & 2 deletions man-roxygen/param_rows.R
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#' @param rows `integer()`\cr
#' Row indices.
#' @param rows (positive `integer()`)\cr
#' Vector or row indices.
2 changes: 1 addition & 1 deletion man/DataBackend.Rd

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

24 changes: 12 additions & 12 deletions man/DataBackendDataTable.Rd

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

24 changes: 12 additions & 12 deletions man/DataBackendMatrix.Rd

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

30 changes: 15 additions & 15 deletions man/Task.Rd

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

8 changes: 4 additions & 4 deletions man/TaskClassif.Rd

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

4 changes: 2 additions & 2 deletions man/TaskRegr.Rd

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

4 changes: 2 additions & 2 deletions man/TaskSupervised.Rd

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

0 comments on commit 855bc2b

Please sign in to comment.