Skip to content

Harmonize errors for set_mode() and set_engine() #503

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

Merged
merged 6 commits into from
May 24, 2021
Merged

Conversation

juliasilge
Copy link
Member

Closes #494

This PR harmonizes the errors (previously a mix of warnings + errors) for set_mode() and set_engine(). I made little functions for the error messages and removed the functionality to choose a default engine, as we discussed. Folks will now get results like this for the engine:

library(parsnip)
linear_reg() %>% set_engine()
#> Error: Available engines are: 'lm', 'glmnet', 'stan', 'spark', 'keras'
linear_reg() %>% set_engine(NULL)
#> Error: Available engines are: 'lm', 'glmnet', 'stan', 'spark', 'keras'
linear_reg() %>% set_engine(3)
#> Error: Available engines are: 'lm', 'glmnet', 'stan', 'spark', 'keras'
linear_reg() %>% set_engine("ranger")
#> Error: Available engines are: 'lm', 'glmnet', 'stan', 'spark', 'keras'

Created on 2021-05-21 by the reprex package (v2.0.0)

And this for mode:

library(parsnip)
logistic_reg() %>% set_mode()
#> Error: Available modes are: 'unknown', 'classification'
logistic_reg() %>% set_mode(NULL)
#> Error: Available modes are: 'unknown', 'classification'
logistic_reg() %>% set_mode(42)
#> Error: Available modes are: 'unknown', 'classification'
logistic_reg() %>% set_mode("regression")
#> Error: Available modes are: 'unknown', 'classification'

rand_forest() %>% set_mode()
#> Error: Available modes are: 'unknown', 'classification', 'regression'
rand_forest() %>% set_mode(NULL)
#> Error: Available modes are: 'unknown', 'classification', 'regression'
rand_forest() %>% set_mode("ranger")
#> Error: Available modes are: 'unknown', 'classification', 'regression'

Created on 2021-05-21 by the reprex package (v2.0.0)

@juliasilge juliasilge requested a review from DavisVaughan May 21, 2021 19:06
@github-actions
Copy link

github-actions bot commented Jun 8, 2021

This pull request 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 Jun 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

set_engine(object, engine) should be set_engine(object, engine = NULL)
3 participants