Skip to content

Consolidate outcome_names() and .get_tune_outcome_names() #1002

@hfrick

Description

@hfrick

When reviewing #994 I noticed that we have outcome_names() with methods for different objects and also .get_tune_outcome_names() (as part of various .get_tune_*() functions).

We can consolidate .get_tune_outcome_names() with outcome_names.tune_results():

tune/R/outcome-names.R

Lines 53 to 63 in a8f0c05

#' @export
#' @rdname outcome_names
outcome_names.tune_results <- function(x, ...) {
att <- attributes(x)
if (any(names(att) == "outcomes")) {
res <- att$outcomes
} else {
res <- NA_character_
}
res
}

tune/R/utils.R

Lines 208 to 218 in a8f0c05

#' @export
#' @rdname tune_accessor
.get_tune_outcome_names <- function(x) {
x <- attributes(x)
if (any(names(x) == "outcomes")) {
res <- x$outcomes
} else {
res <- character(0)
}
res
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    upkeepmaintenance, infrastructure, and similar

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions