Skip to content

renew cached objects for testing #775

Closed

Description

@topepo

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

Activity

  1. simonpcouch commented on Jan 26, 2024

    @simonpcouch
    Contributor

    Closed by #776🚀

  2. github-actions commented on Feb 10, 2024

    @github-actions
    Contributor

    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.

  3. locked and limited conversation to collaborators on Feb 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions