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

performance issue in will_make_matrix() #885

Closed
simonpcouch opened this issue Feb 23, 2023 · 3 comments
Closed

performance issue in will_make_matrix() #885

simonpcouch opened this issue Feb 23, 2023 · 3 comments
Labels
upkeep maintenance, infrastructure, and similar

Comments

@simonpcouch
Copy link
Contributor

The internal will_make_matrix() function lapply()s on an input that could be atomic:

cls <- unique(unlist(lapply(y, class)))

This approach is quite a bit slower than something like check_outcome():

parsnip/R/misc.R

Lines 344 to 345 in 2588181

outcome_is_factor <- if (is.atomic(y)) {is.factor(y)} else {all(map_lgl(y, is.factor))}
if (!outcome_is_factor) {

Thankfully, most of the time, will_make_matrix() returns early before making it to this condition.

@simonpcouch
Copy link
Contributor Author

Same goes for this vapply():

parsnip/R/convert_data.R

Lines 332 to 334 in 2588181

can_convert <-
vapply(y, function(x)
is.atomic(x) & !is.factor(x), logical(1))

Pass factor(rep(0, 1e5)) to trigger both.

@EmilHvitfeldt EmilHvitfeldt added the upkeep maintenance, infrastructure, and similar label Feb 23, 2023
@simonpcouch
Copy link
Contributor Author

With 81ad6b6 included as part of #888, I'm happy with where this is at now!

@github-actions
Copy link

This issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.

@github-actions github-actions bot locked and limited conversation to collaborators Mar 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
upkeep maintenance, infrastructure, and similar
Projects
None yet
Development

No branches or pull requests

2 participants