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

Allow custom descriptions for obj_type_friendly() #1674

Open
EmilHvitfeldt opened this issue Nov 28, 2023 · 1 comment
Open

Allow custom descriptions for obj_type_friendly() #1674

EmilHvitfeldt opened this issue Nov 28, 2023 · 1 comment

Comments

@EmilHvitfeldt
Copy link
Member

We were trying to add custom checking functions using import-standalone_types_check.R in https://github.com/tidymodels/dials/. And it would be nice if there was a way to add to the ways obj_type_friendly() works without having to modify a file that says This document is read only.

In the below example, it would be nice if we could make it say parameter set instead of the more verbose <parameters/tbl_df/tbl/data.frame>.

check_param <- function(x, 
                        ..., 
                        allow_na = FALSE, 
                        allow_null = FALSE, 
                        arg = caller_arg(x), 
                        call = caller_env()) {
  if (!missing(x) && inherits(x, "param")) {    
    return(invisible(NULL))  
  }  
  
  stop_input_type(
    x,
    c("a single parameter object"),
    ...,
    allow_na = allow_na,
    allow_null = allow_null,
    arg = arg,
    call = call
  )
}

library(dials)
#> Loading required package: scales



param <- mtry()
check_param(param)

parameter_set <- parameters(param)
check_param(parameter_set)
#> ERROR:
#> ! `parameter_set` must be a single parameter object, not a <parameters/tbl_df/tbl/data.frame> object.
@lionel-
Copy link
Member

lionel- commented Nov 29, 2023

Would you like to send a PR to implement this change?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants