Skip to content

Empty input -> empty output or error? #428

@hfrick

Description

@hfrick

We generally like the "empty input, empty output" pattern.

I suspect this inconsistency comes from how we use them in downstream tidymodels packages, so if we switch to the "empty input, empty output" pattern, we need to check that nothing falls over downstream.

Here are two examples; there might be more/the other grid functions should work the same way as grid_regular().

library(dials)
#> Loading required package: scales

# not allowed
parameters() 
#> Error:
#> ! ! Could not evaluate cli `{}` expression: `x`.
#> Caused by error in `eval(expr, envir = envir)`:
#> ! argument "x" is missing, with no default

# allowed
parameters(list()) 
#> Collection of 0 parameters for tuning
#> 
#> [1] identifier type       object    
#> <0 rows> (or 0-length row.names)
#> 

# not allowed
grid_regular() 
#> Error in `UseMethod()`:
#> ! no applicable method for 'grid_regular' applied to an object of class "NULL"

# also not allowed 
grid_regular(list()) 
#> Error in `grid_regular()`:
#> ! At least one parameter object is required.

Created on 2026-02-23 with reprex v2.1.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    featurea feature request or enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions