Skip to content

Cli errors for validation_set and vfold. - #532

Merged
hfrick merged 7 commits into
tidymodels:mainfrom
PriKalra:cliErrorRssample514
Sep 11, 2024
Merged

Cli errors for validation_set and vfold.#532
hfrick merged 7 commits into
tidymodels:mainfrom
PriKalra:cliErrorRssample514

Conversation

@PriKalra

@PriKalra PriKalra commented Aug 29, 2024

Copy link
Copy Markdown
Contributor

fixes #514

I have changed some styling with Cli abort. there are 5 failed tests the are arising from Validation_set and vfold. I ran the cli_abort in a local context and they throw the errors correctly- so I think there is a clash with the way tests are written?
Let me know if there are further improvements in the errors required by me:

── Failed tests ────────────────────────────────────────────────────────────────────────────────────────────
Failure (test-clustering.R:43:3): bad args
Snapshot of `clustering_cv(iris, Sepal.Length, v = 500)` has changed:
    old                                       | new                                          
[1] The number of rows is less than `v = 500` - The number of rows is less than `v` = 500 [1]

* Run testthat::snapshot_accept('clustering') to accept the change.
* Run testthat::snapshot_review('clustering') to interactively review the change.

Failure (test-validation_set.R:38:3): accessor functions for `val_split`
Snapshot of code has changed:
old[2:5] vs new[2:6]
    testing(val_split)
  Condition
    Error in `testing()`:
-   ! The testing data is not part of the validation set object.
+   x The testing data is not part of the validation set object.
+   i It is part of the result of the initial 3-way split, e.g., with `initial_validation_split()`.

* Run testthat::snapshot_accept('validation_set') to accept the change.
* Run testthat::snapshot_review('validation_set') to interactively review the change.

Failure (test-vfold.R:84:3): bad args
Snapshot of `vfold_cv(iris, v = 500)` has changed:
    old                                       | new                                          
[1] The number of rows is less than `v = 500` - The number of rows is less than `v` = 500 [1]

* Run testthat::snapshot_accept('vfold') to accept the change.
* Run testthat::snapshot_review('vfold') to interactively review the change.

Failure (test-vfold.R:85:3): bad args
Snapshot of `vfold_cv(iris, v = 150, repeats = 2)` has changed:
lines(old) vs lines(new)
- "Repeated resampling when `v` is 150 would create identical resamples"
+ "x Repeated resampling when `v` is 150 would create identical resamples"
+ "i Consider adjusting the value of `v` to avoid identical resamples."

* Run testthat::snapshot_accept('vfold') to accept the change.
* Run testthat::snapshot_review('vfold') to interactively review the change.

Failure (test-vfold.R:116:3): grouping -- bad args
Snapshot of `group_vfold_cv(dat1, c, repeats = 4)` has changed:
old vs new
- Repeated resampling when `v` is `NULL` would create identical resamples
+ Repeated resampling when `v` is "NULL" would create identical resamples

* Run testthat::snapshot_accept('vfold') to accept the change.
* Run testthat::snapshot_review('vfold') to interactively review the change.

@hfrick
hfrick merged commit 77ab7df into tidymodels:main Sep 11, 2024
@hfrick

hfrick commented Sep 11, 2024

Copy link
Copy Markdown
Member

@PriKalra The snapshots capture how the error is supposed to look and the snapshot tests compare the current version of the error to those snapshots. So when you change how an error looks, it doesn't match the snapshot anymore and the corresponding test fails. If the change is what you want, you can update the reference, the snapshot. This part of the output

* Run testthat::snapshot_accept('vfold') to accept the change.
* Run testthat::snapshot_review('vfold') to interactively review the change.

tells you both how to review the changes to decide on whether or not they were want you intended and how to update the snapshot to the new version ("accept the changes").

Does this clear things up or did I misinterpet your comment?

Nothing further needed, thank so much for all the changes! 🙏

@hfrick hfrick changed the title There are snapshot test errors for validation_set and vfold. Cli errors for validation_set and vfold. Sep 11, 2024
@github-actions

Copy link
Copy Markdown
Contributor

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 Sep 27, 2024
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.

Use cli errors in R/tidy.R, R/validation_set.R, R/vfold.R

2 participants