Skip to content

Internals bug? will_make_matrix() returns False when given a matrix #786

@joeycouse

Description

@joeycouse

Hello, I'm working on a PR to address #765. While doing so I ran into an issue with will_make_matrix(). Shouldn't the return value be True if y is a matrix or a vector?

When y is a numeric matrix it fails this check and converts it to a vector. This is stripping the colname of y whenever it is passed to function later down the line such as xgb_train()

parsnip/R/convert_data.R

Lines 326 to 336 in f081091

will_make_matrix <- function(y) {
if (is.matrix(y) | is.vector(y))
return(FALSE)
cls <- unique(unlist(lapply(y, class)))
if (length(cls) > 1)
return(FALSE)
can_convert <-
vapply(y, function(x)
is.atomic(x) & !is.factor(x), logical(1))
all(can_convert)
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions