Skip to content
Draft
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: 2 additions & 1 deletion .lintr
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ linters: linters_with_defaults(
object_name_linter = object_name_linter(c("snake_case", "CamelCase")), # only allow snake case and camel case object names
cyclocomp_linter = NULL, # do not check function complexity
commented_code_linter = NULL, # allow code in comments
line_length_linter = line_length_linter(120)
line_length_linter = line_length_linter(120),
indentation_linter = indentation_linter(indent = 2, hanging_indent_style = "never")
)
4 changes: 3 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ Suggests:
evaluate,
mirai,
paradox,
testthat (>= 3.0.0)
testthat (>= 3.0.0),
utils
Config/testthat/edition: 3
Config/testthat/parallel: true
Encoding: UTF-8
Expand All @@ -44,6 +45,7 @@ Collate:
'named_list.R'
'Callback.R'
'Context.R'
'Mlr3Component.R'
'as_factor.R'
'as_short_string.R'
'assert_ro_binding.R'
Expand Down
3 changes: 3 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ S3method(distinct_values,logical)
S3method(format,Mlr3Error)
S3method(format,Mlr3Warning)
S3method(hash_input,"function")
S3method(hash_input,R6)
S3method(hash_input,data.table)
S3method(hash_input,default)
S3method(insert_named,"NULL")
Expand Down Expand Up @@ -46,6 +47,7 @@ export("get_private<-")
export(Callback)
export(Context)
export(Dictionary)
export(Mlr3Component)
export(as_callback)
export(as_callbacks)
export(as_factor)
Expand Down Expand Up @@ -128,6 +130,7 @@ export(map_int)
export(map_lgl)
export(map_values)
export(messagef)
export(mlr3component_deprecation_msg)
export(mlr_callbacks)
export(modify_at)
export(modify_if)
Expand Down
466 changes: 466 additions & 0 deletions R/Mlr3Component.R

Large diffs are not rendered by default.

15 changes: 13 additions & 2 deletions R/calculate_hash.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@
#'
#' @param ... (`any`)\cr
#' Objects to hash.
#' @param .list (`list()`)\cr
#' Additional objects to hash.
#'
#' @return (`character(1)`).
#' @export
#' @examples
#' calculate_hash(iris, 1, "a")
calculate_hash = function(...) {
digest(lapply(list(...), hash_input), algo = "xxhash64")
calculate_hash = function(..., .list = list()) {
digest(lapply(c(list(...), .list), hash_input), algo = "xxhash64")
}

#' Hash Input
Expand Down Expand Up @@ -54,3 +56,12 @@ hash_input.default = function(x) {
x
}

#' @describeIn hash_input
#' If the R6 object has a `$hash` slot, it is returned.
#' Otherwise, the object is returned as is.
#' @export
hash_input.R6 = function(x) {
# In the following we also avoid accessing `val$hash` twice, because it could
# potentially be an expensive AB.
get0("hash", x, mode = "any", inherits = FALSE, ifnotfound = x)
}
2 changes: 1 addition & 1 deletion R/topo_sort.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ topo_sort = function(nodes) {
}
j = (j %% n) + 1L # inc j, but wrap around end
if (j == 1L) { # we wrapped, lets remove nodes of current layer from deps
layer = nodes[.(depth_count), id, on = "depth", nomatch = NULL]
layer = nodes[list(depth_count), id, on = "depth", nomatch = NULL]
if (length(layer) == 0L) {
stop("Cycle detected, this is not a DAG!")
}
Expand Down
Loading