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

renew cached objects for testing #775

Closed
topepo opened this issue Dec 2, 2023 · 2 comments
Closed

renew cached objects for testing #775

topepo opened this issue Dec 2, 2023 · 2 comments

Comments

@topepo
Copy link
Member

topepo commented Dec 2, 2023

Scales 1.3.0 made a change in the object class of its transformers. Their new class ("transformers") is not compatible with the old class (see below). We need to recreate these with the new version of scales.

library(tidymodels)
library(testthat)
#> 
#> Attaching package: 'testthat'
#> The following object is masked from 'package:tidyr':
#> 
#>     matches
#> The following object is masked from 'package:rsample':
#> 
#>     matches
#> The following object is masked from 'package:purrr':
#> 
#>     is_null
#> The following object is masked from 'package:dplyr':
#> 
#>     matches
library(scales)
tidymodels_prefer()
theme_set(theme_bw())
options(pillar.advice = FALSE, pillar.min_title_chars = Inf)
# uses old format transformers (pre scales v 1.3.0)

# Get current cached test object
temp_loc <- tempfile()
download.file(
  "https://github.com/tidymodels/tune/raw/main/tests/testthat/data/svm_reg_results.rds", 
  temp_loc)

svm_reg_results <- readRDS(temp_loc)
autoplot(svm_reg_results)
#> Error in `as.trans()`:
#> ! `trans` must be a character vector or a transformer object
#> Backtrace:
#>     ▆
#>  1. ├─ggplot2::autoplot(svm_reg_results)
#>  2. └─tune:::autoplot.tune_results(svm_reg_results)
#>  3.   └─tune:::plot_regular_grid(...) at tune/R/plots.R:106:11
#>  4.     └─ggplot2::scale_x_continuous(trans = trans) at tune/R/plots.R:634:5
#>  5.       └─ggplot2::continuous_scale(...)
#>  6.         └─scales::as.trans(trans)
#>  7.           └─cli::cli_abort(...)
#>  8.             └─rlang::abort(...)

# The dials objects are in the pre-made parameter sets 

dials_params <- tune:::get_param_object(svm_reg_results)
dials_params
#> Collection of 3 parameters for tuning
#> 
#>    identifier         type    object
#>          cost         cost nparam[+]
#>          %^*#       degree nparam[+]
#>  scale_factor scale_factor nparam[+]

scale_trans_obj <- dials_params$object[[3]]$trans

# with new scales: 
class(scale_trans_obj)
#> [1] "trans"
is.trans(scale_trans_obj)
#> [1] FALSE
as.trans(scale_trans_obj)
#> Error in `as.trans()`:
#> ! `scale_trans_obj` must be a character vector or a transformer object
#> Backtrace:
#>     ▆
#>  1. └─scales::as.trans(scale_trans_obj)
#>  2.   └─cli::cli_abort(...)
#>  3.     └─rlang::abort(...)

Created on 2023-12-02 with reprex v2.0.2

topepo added a commit that referenced this issue Dec 4, 2023
* no tidier for knn objects

* regenerate results with objects from scales v 1.3.0

* remake errors in test objects ¯\\_(ツ)_/¯

* remove for fairness changes

* make a scales version requirement
topepo added a commit that referenced this issue Dec 6, 2023
* move function to new file

* change function order for docs

* documentation start

* updates to the show/select functions

* updates to select/show functions

* updates for selecting eval times

* remove commented out code

* bug fix

* metric test cases

* add a survival model object

* note for next PR

* select/show test cases

* small set of direct tests

* update snapshot

* Apply suggestions from code review

Co-authored-by: Hannah Frick <hfrick@users.noreply.github.com>

* Apply suggestions from code review

* updates from previous review

* small cli update

* doc update

* refresh snapshots

* modularize a check

* Remake with newest CRAN version of scales for #775

* Apply suggestions from code review

Co-authored-by: Hannah Frick <hfrick@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: Hannah Frick <hfrick@users.noreply.github.com>

* add dot when function is invoked

* add a warning for eval times with non-survival models

* go back to enquos

* rework warning text

* rework warning text pt 2

---------

Co-authored-by: Hannah Frick <hfrick@users.noreply.github.com>
topepo added a commit that referenced this issue Dec 11, 2023
…#780)

* move function to new file

* change function order for docs

* documentation start

* updates to the show/select functions

* updates to select/show functions

* updates for selecting eval times

* remove commented out code

* bug fix

* metric test cases

* add a survival model object

* note for next PR

* select/show test cases

* small set of direct tests

* update snapshot

* Apply suggestions from code review

Co-authored-by: Hannah Frick <hfrick@users.noreply.github.com>

* Apply suggestions from code review

* updates from previous review

* small cli update

* doc update

* refresh snapshots

* modularize a check

* Remake with newest CRAN version of scales for #775

* argument checks for tune functions

* Apply suggestions from code review

Co-authored-by: Hannah Frick <hfrick@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: Hannah Frick <hfrick@users.noreply.github.com>

* add dot when function is invoked

* add a warning for eval times with non-survival models

* go back to enquos

* rework warning text

* rework warning text pt 2

* unit tests for regression and classification

* caller envs

* unit tests

* rework call envs

* survival unit tests

* Apply suggestions from code review

Co-authored-by: Hannah Frick <hfrick@users.noreply.github.com>

* update tests for more recent version of yardstick

* use standalone file from tidymodels/parsnip#1034

---------

Co-authored-by: Hannah Frick <hfrick@users.noreply.github.com>
@simonpcouch
Copy link
Contributor

Closed by #776🚀

Copy link

This issue 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 Feb 10, 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

No branches or pull requests

2 participants