-
Notifications
You must be signed in to change notification settings - Fork 33
Improve type-checking #414
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
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
3c9d509
add Claude
hfrick 4031e34
improve `check_label()`
hfrick 68c99df
improve `check_values_quant()`
hfrick 7c5cc47
Improve `check_inclusive()`
hfrick 141cc09
Fix test
hfrick 382bc23
Improve `check_range()`
hfrick 7c1cba5
Improve `range_validate()`
hfrick File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,3 +21,6 @@ | |
| ^CRAN-SUBMISSION$ | ||
| ^[\.]?air\.toml$ | ||
| ^\.vscode$ | ||
|
|
||
| CLAUDE.md | ||
| ^\.claude$ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| # CLAUDE.md | ||
|
|
||
| This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. | ||
|
|
||
| ## Overview | ||
|
|
||
| dials is an R package that provides infrastructure for creating and managing tuning parameter values in the tidymodels ecosystem. It defines parameter objects, sets of parameters, and methods for generating parameter grids for model tuning. | ||
|
|
||
| ## Key development commands | ||
|
|
||
| General advice: | ||
| * When running R from the console, always run it with `--quiet --vanilla` | ||
| * Always run `air format .` after generating code | ||
|
|
||
| ### Testing | ||
|
|
||
| - Use `devtools::test()` to run all tests | ||
| - Use `devtools::test_file("tests/testthat/test-filename.R")` to run tests in a specific file | ||
| - DO NOT USE `devtools::test_active_file()` | ||
| - All testing functions automatically load code; you don't need to. | ||
|
|
||
| - All new code should have an accompanying test. | ||
| - Tests for `R/{name}.R` go in `tests/testthat/test-{name}.R`. | ||
| - If there are existing tests, place new tests next to similar existing tests. | ||
|
|
||
| ### Documentation | ||
|
|
||
| - Run `devtools::document()` after changing any roxygen2 docs. | ||
| - Every user facing function should be exported and have roxygen2 documentation. | ||
| - Whenever you add a new documentation file, make sure to also add the topic name to `_pkgdown.yml`. | ||
| - Run `pkgdown::check_pkgdown()` to check that all topics are included in the reference index. | ||
| - Use sentence case for all headings | ||
|
|
||
|
|
||
| ## Architecture | ||
|
|
||
| ### Core Parameter System | ||
|
|
||
| The package is built around two main parameter types: | ||
|
|
||
| 1. **`quant_param`**: Quantitative parameters (continuous or integer) | ||
| - Created via `new_quant_param()` in `R/constructors.R` | ||
| - Has `range` (lower/upper bounds), `inclusive`, optional `trans` (transformation), and `finalize` function | ||
| - Examples: `penalty()`, `mtry()`, `learn_rate()` | ||
|
|
||
| 2. **`qual_param`**: Qualitative parameters (categorical) | ||
| - Created via `new_qual_param()` in `R/constructors.R` | ||
| - Has discrete `values` (character or logical) | ||
| - Examples: `activation()`, `weight_func()` | ||
|
|
||
| ### Parameter Organization | ||
|
|
||
| - **Individual parameters**: parameter definition files (`R/param_*.R`), each defining specific tuning parameters used across tidymodels | ||
| - **Parameter sets**: The `parameters` class (defined in `R/parameters.R`) groups multiple parameters into a data frame-like structure | ||
|
|
||
| ### Grid Generation | ||
|
|
||
| Three main grid types (in `R/grids.R` and `R/space_filling.R`): | ||
|
|
||
| 1. **Regular grids** (`grid_regular()`): Factorial designs with evenly-spaced values | ||
| 2. **Random grids** (`grid_random()`): Random sampling from parameter ranges | ||
| 3. **Space-filling grids** (`grid_space_filling()`): Experimental designs (Latin hypercube, max entropy, etc.) that efficiently cover the parameter space | ||
|
|
||
| All grid functions: | ||
| - Accept parameter objects or parameter sets | ||
| - Return tibbles with one column per parameter | ||
|
|
||
| ### Finalization System | ||
|
|
||
| Many parameters have `unknown()` ranges that depend on the dataset (e.g., `mtry()` depends on the number of predictors). The finalization system (`R/finalize.R`) resolves these: | ||
|
|
||
| - `finalize()`: Generic function that calls the parameter's embedded `finalize` function | ||
| - `get_*()`: Various functions that get and set parameter ranges based on data characteristics | ||
|
|
||
| ### Infrastructure Files | ||
|
|
||
| Files prefixed with `aaa_` load first and define foundational classes: | ||
| - `R/aaa_ranges.R`: Handling and validation of parameter ranges | ||
| - `R/aaa_unknown.R`: The `unknown()` placeholder for unspecified parameter bounds | ||
| - `R/aaa_values.R`: Validation, generation, and transformation of parameter values | ||
|
|
||
| Files prefixed with `compat-` provide compatibility with dplyr and vctrs for parameter objects. | ||
|
|
||
| ## Integration with tidymodels | ||
|
|
||
| dials is infrastructure-level; it defines parameters but doesn't perform tuning. The tune package uses dials for actual hyperparameter tuning. Parameter objects integrate with: | ||
| - **parsnip**: Model specifications reference dials parameters | ||
| - **recipes**: Preprocessing steps use dials parameters | ||
| - **workflows**: Workflows combine models and preprocessing that utilize dials parameters | ||
| - **tune**: Grid search and optimization consume parameter grids |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created on 2026-01-25 with reprex v2.1.1