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

Add missing snapshots - part 1 #1383

Merged
merged 12 commits into from
Oct 25, 2024
Merged

Add missing snapshots - part 1 #1383

merged 12 commits into from
Oct 25, 2024

Conversation

EmilHvitfeldt
Copy link
Member

I didn't get all of them done in this round. and it wouldn't hurt to split them up

Comment on lines -132 to -138
if (length(col_name) > 1) {
cli::cli_abort(c(
x = "The selector should select at most a single variable.",
i = "The following {length(col_name)} were selected: \\
{.and {.var {col_name}}}."
))
}
Copy link
Member Author

Choose a reason for hiding this comment

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

this is unreachable because we are already checking for this in step_count() in line 83

Comment on lines -136 to -140
if (!is.numeric(var)) {
cli::cli_abort(
"{.arg var} must be a numeric vector, not {.obj_type_friendly {var}}."
)
}
Copy link
Member Author

Choose a reason for hiding this comment

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

this is no longer needed as we do the checking with `check_type()

Comment on lines -207 to -212
if (!is.factor(x)) {
cli::cli_abort(
"{.arg x} must be a factor, not {.obj_type_friendly {x}}.",
.internal = TRUE
)
}
Copy link
Member Author

Choose a reason for hiding this comment

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

didn't feel like this was needed, since adjust_levels_min_max() is used on the output of cut() which should always be a factor.

I checked, and if cut() were to produce a non-factor, then other errors go off

Comment on lines -274 to -277
if (is.null(levels_values)) {
cli::cli_abort("Factor level values not recorded in {.var col_name}.")
}

Copy link
Member Author

Choose a reason for hiding this comment

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

unreachable as we require that step_dummy() is done on factors

@@ -165,23 +163,6 @@ prep.step_dummy_multi_choice <- function(x, training, info = NULL, ...) {
)
}

multi_dummy_check_type <- function(dat, call = rlang::caller_env()) {
Copy link
Member Author

Choose a reason for hiding this comment

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

no longer needed due to check_type()

Copy link
Contributor

Choose a reason for hiding this comment

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

SATISFYING

Comment on lines -116 to -118
if (!is.numeric(trim) || length(trim) != 1L) {
cli::cli_abort("{.arg trim} must be numeric of length one.")
}
Copy link
Member Author

Choose a reason for hiding this comment

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

technically unreachable, since there is a if (trim == 0) {} above. but also isn't needed since it should be a rlang type checked earlier anyways

Comment on lines -121 to -123
if (is.complex(x)) {
cli::cli_abort("Trimmed means are not defined for complex data.")
}
Copy link
Member Author

Choose a reason for hiding this comment

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

can't be reached since check_type() doesn't allow complex data

@@ -162,7 +162,8 @@ prep.step_interact <- function(x, training, info = NULL, ...) {
)
if (!is_formula(tmp_terms)) {
cli::cli_abort(
"{.arg terms} must be a formula. Not {.obj_type_friendly {term}}."
"{.arg terms} must be a formula. Not {.obj_type_friendly {term}}.",
.internal = TRUE
Copy link
Member Author

Choose a reason for hiding this comment

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

I have in a couple of places added .internal = TRUE. I did this because I was not able to find a reprex, but it felt reasonable that it could happen.


# Get existing levels and their factor type (i.e. ordered)
objects <- lapply(training[, col_names], get_existing_values)
# Check to make sure that no ordered levels are provided
order_check <- map_lgl(objects, attr, "is_ordered")
if (any(order_check)) {
Copy link
Member Author

Choose a reason for hiding this comment

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

isn't needed as we can do it with check_type()

R/cut.R Show resolved Hide resolved
@@ -118,7 +118,7 @@ step_impute_knn <-
if (length(options) > 0) {
if (any(!(opt_nms %in% c("eps", "nthread")))) {
Copy link
Member

Choose a reason for hiding this comment

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

rlang::arg_match()?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm planning to add a helper function for this as we pass through additional arguments in a list a few places
#1269

R/pls.R Show resolved Hide resolved
Copy link
Contributor

@simonpcouch simonpcouch left a comment

Choose a reason for hiding this comment

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

groovy!🏄‍♀️

R/colcheck.R Outdated Show resolved Hide resolved
R/cut.R Show resolved Hide resolved
@@ -165,23 +163,6 @@ prep.step_dummy_multi_choice <- function(x, training, info = NULL, ...) {
)
}

multi_dummy_check_type <- function(dat, call = rlang::caller_env()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

SATISFYING

R/interact.R Outdated Show resolved Hide resolved
R/interact.R Outdated Show resolved Hide resolved
R/nnmf_sparse.R Outdated Show resolved Hide resolved
R/profile.R Outdated Show resolved Hide resolved
tests/testthat/_snaps/date.md Outdated Show resolved Hide resolved
tests/testthat/_snaps/dummy.md Show resolved Hide resolved
options = list(kernel = "wrong")) %>% prep()
Condition
Warning:
`step_pls()` failed with error: Error in mixOmics::pls(X = x, Y = y, ncomp = 2, kernel = ~"wrong") : unused argument (kernel = ~"wrong") .
Copy link
Contributor

Choose a reason for hiding this comment

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

Lots of formatting here that I suspect would be pared back by just setting parent

Copy link
Member Author

Choose a reason for hiding this comment

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

talk more here: #1386

@EmilHvitfeldt EmilHvitfeldt merged commit 5b29dc6 into main Oct 25, 2024
11 checks passed
@EmilHvitfeldt EmilHvitfeldt deleted the add-snapshots branch October 25, 2024 16:19
Copy link

github-actions bot commented Nov 9, 2024

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 Nov 9, 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.

3 participants