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

Use check_name() in all steps that produces new columns #1124

Merged
merged 41 commits into from Apr 11, 2023

Conversation

EmilHvitfeldt
Copy link
Member

@EmilHvitfeldt EmilHvitfeldt commented Apr 5, 2023

This PR aims to close #983

This PR did 4 things:

  • added check_name() to all steps that should have them for didn't
  • Added tests to all steps that uses check_name()
  • updated check_name() to use {cli}
  • updated check_name() to pass call around to improve error message

Demo:

library(recipes)

recipe(~ ., data = mtcars) |>
  step_pca(mpg, disp, vs) |>
  prep() |>
  bake(new_data = NULL)
#> # A tibble: 32 × 11
#>      cyl    hp  drat    wt  qsec    am  gear  carb   PC1   PC2     PC3
#>    <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>   <dbl>
#>  1     6   110  3.9   2.62  16.5     1     4     4 -161. 11.5   0.556 
#>  2     6   110  3.9   2.88  17.0     1     4     4 -161. 11.5   0.556 
#>  3     4    93  3.85  2.32  18.6     1     4     1 -109. 16.4  -0.310 
#>  4     6   110  3.08  3.22  19.4     0     3     1 -259.  6.13 -0.556 
#>  5     8   175  3.15  3.44  17.0     0     3     2 -360. -2.63  0.213 
#>  6     6   105  2.76  3.46  20.2     0     3     1 -226.  4.79 -0.633 
#>  7     8   245  3.21  3.57  15.8     0     3     4 -360. -7.01  0.0531
#>  8     4    62  3.69  3.19  20       0     4     2 -148. 15.7  -0.302 
#>  9     4    95  3.92  3.15  22.9     0     4     2 -142. 14.5  -0.353 
#> 10     6   123  3.92  3.44  18.3     0     4     4 -168.  9.28 -0.519 
#> # ℹ 22 more rows

mtcars$PC1 <- mtcars$mpg

recipe(~ ., data = mtcars) |>
  step_pca(mpg, disp, vs) |>
  prep()
#> Error in `step_pca()`:
#> Caused by error in `bake()`:
#> ! Name collision occured. The following variable names already exists:
#> ℹ  PC1

Revdepcheck

── CHECK ────────────────────────────────────────────────────────────────── 62 packages ──
✔ applicable 0.1.0                       ── E: 0     | W: 0     | N: 0actxps 1.0.0                           ── E: 0  +1 | W: 0     | N: 0additive 0.0.5                         ── E: 0     | W: 0     | N: 0agua 0.1.2                             ── E: 0     | W: 0     | N: 1baguette 1.0.1                         ── E: 0     | W: 0     | N: 0autostats 0.4.0                        ── E: 0     | W: 0     | N: 0bayesian 0.0.9                         ── E: 0     | W: 0     | N: 0bestNormalize 1.9.0                    ── E: 0     | W: 0     | N: 0brulee 0.2.0                           ── E: 0     | W: 0     | N: 0butcher 0.3.2                          ── E: 0     | W: 0     | N: 0card 0.1.0                             ── E: 0     | W: 0     | N: 1bundle 0.1.0                           ── E: 1     | W: 0     | N: 0correlationfunnel 0.2.0                ── E: 0     | W: 0     | N: 1caret 6.0.94                           ── E: 0     | W: 0     | N: 0CSCNet 0.1.2                           ── E: 0     | W: 0     | N: 0                    
I D2MCS 1.0.1                            ── E: 1     | W: 0     | N: 0cvms 1.3.9                             ── E: 0     | W: 0     | N: 0easyalluvial 0.3.1                     ── E: 0     | W: 0     | N: 0DALEXtra 2.2.1                         ── E: 0     | W: 0     | N: 0finetune 1.0.1                         ── E: 0     | W: 0     | N: 0embed 1.0.0                            ── E: 0     | W: 0     | N: 0healthcareai 2.5.1                     ── E: 2     | W: 0     | N: 1finnts 0.2.2                           ── E: 0     | W: 0     | N: 0hardhat 1.3.0                          ── E: 0     | W: 0     | N: 0HTRX 1.2.2                             ── E: 0     | W: 0     | N: 1healthyR.ai 0.0.13                     ── E: 0     | W: 0     | N: 0                    
I hydrorecipes 0.0.3                     ── E: 1     | W: 0     | N: 0healthyR.ts 0.2.7                      ── E: 0     | W: 0     | N: 1MLDataR 1.0.1                          ── E: 0     | W: 0     | N: 1modelgrid 1.1.1.0                      ── E: 0     | W: 0     | N: 2MachineShop 3.6.2                      ── E: 0     | W: 0     | N: 0modeltime 1.2.6                        ── E: 0     | W: 0     | N: 1modeltime.ensemble 1.0.2               ── E: 0     | W: 0     | N: 1modeltime.resample 0.2.2               ── E: 0     | W: 0     | N: 1palmerpenguins 0.1.1                   ── E: 0     | W: 0     | N: 0nestedmodels 1.0.4                     ── E: 0     | W: 0     | N: 0rsample 1.1.1                          ── E: 0     | W: 0     | N: 0rules 1.0.2                            ── E: 0     | W: 0     | N: 0shinyrecipes 0.1.0                     ── E: 0     | W: 0     | N: 1SomaDataIO 6.0.0                       ── E: 0     | W: 0     | N: 0sknifedatar 0.1.2                      ── E: 0     | W: 0     | N: 0stabiliser 1.0.2                       ── E: 1     | W: 0     | N: 0sparseR 0.2.2                          ── E: 0     | W: 0     | N: 0stacks 1.0.1                           ── E: 0     | W: 0     | N: 0swag 0.1.0                             ── E: 0     | W: 0     | N: 0tabnet 0.3.0                           ── E: 0     | W: 0     | N: 0text 0.9.99.2                          ── E: 0     | W: 0     | N: 1textrecipes 1.0.2                      ── E: 0     | W: 0     | N: 1tfhub 0.8.1                            ── E: 1     | W: 0     | N: 0themis 1.0.0                           ── E: 0     | W: 0     | N: 0tidyAML 0.0.1                          ── E: 0     | W: 0     | N: 0tidybins 0.1.0                         ── E: 0     | W: 0     | N: 1tidyclust 0.1.2                        ── E: 0     | W: 0     | N: 0tidymodels 1.0.0                       ── E: 0     | W: 0     | N: 1tune 1.1.0                             ── E: 0     | W: 0     | N: 0timetk 2.8.3                           ── E: 0     | W: 0     | N: 1usemodels 0.2.0                        ── E: 0     | W: 0     | N: 0vetiver 0.2.0                          ── E: 0     | W: 0     | N: 0workboots 0.2.0                        ── E: 0     | W: 0     | N: 0waywiser 0.3.0                         ── E: 0     | W: 0     | N: 1workflows 1.1.3                        ── E: 0     | W: 0     | N: 0workflowsets 1.0.0                     ── E: 0     | W: 0     | N: 0                    
OK: 61                                                                                  
BROKEN: 1
Total time: 26 min

The problem in actxps is unrelated to this change and can be found here: mattheaphy/actxps#30

Copy link
Member

@hfrick hfrick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So nice! 🐈‍⬛ 🧁 I have one question about the call that does show up, see direct code comments

tests/testthat/_snaps/bs.md Show resolved Hide resolved
@EmilHvitfeldt EmilHvitfeldt merged commit bea2ec9 into main Apr 11, 2023
9 checks passed
@github-actions
Copy link

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 Apr 26, 2023
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.

Make sure check_name() is used everywhere it needs to be used
2 participants