tidymodels / tidymodels/dials

Empty input -> empty output or error?

Open
#428 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature
Dominant language
R
Stars
117
Forks
36
Avg merge
1h 53m
Merged PRs (30d)
2

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the examples for parameters() and grid_regular(), then inspect the other grid functions for inconsistent handling of empty inputs. Check downstream tidymodels usage as the issue requests, and consider the work done when the chosen empty-input behavior is consistent without downstream failures.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
api
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.