Skip to content

Remove redundant test on trunc_probs() #970

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

Merged
merged 1 commit into from
May 17, 2023
Merged

Conversation

hfrick
Copy link
Member

@hfrick hfrick commented May 15, 2023

I think the test removed in this PR is mainly to test aspects which are already covered by the other test on trunc_probs(). I'll comment with links :)

these aspects are already covered by the other test
probs_2 <- probs_1
probs_2[3] <- NA_real_

expect_equal(parsnip:::trunc_probs(probs_1, 0), probs_1)
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 covers "leave probs untouched" and "check the full vector", both of which are covered by

probs <- (1:200)/200
expect_identical(
parsnip:::trunc_probs(probs, trunc = 0.01),
probs
)

probs_2[3] <- NA_real_

expect_equal(parsnip:::trunc_probs(probs_1, 0), probs_1)
expect_equal(parsnip:::trunc_probs(probs_2, 0), probs_2)
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 one adds an NA which is also part of the following, the whole vector is just covered over multiple expectations

probs_trunc_04_na <- parsnip:::trunc_probs(c(NA, probs), 0.4)
expect_identical(probs_trunc_04_na[1], NA_real_)
expect_equal(probs_trunc_04_na[2], data_derived_trunc)
expect_equal(probs_trunc_04_na[3:6], probs[2:5])

Comment on lines -32 to -35
expect_equal(
parsnip:::trunc_probs(probs_1, 0.1),
ifelse(probs_1 < 0.05 / 2, 0.05 / 2, probs_1)
)
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 checks for what I called "data derived truncation" in

probs_trunc_04 <- parsnip:::trunc_probs(probs, trunc = 0.4)
data_derived_trunc <- min(probs[probs > 0]) / 2
expect_equal(probs_trunc_04[1], data_derived_trunc)
expect_equal(probs_trunc_04[2:5], probs[2:5])

Comment on lines -36 to -38
expect_equal(min(parsnip:::trunc_probs(probs_2, 0.1), na.rm = TRUE), 0.05 / 2)
expect_equal(is.na(parsnip:::trunc_probs(probs_2, 0.1)),is.na(probs_2))
})
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 one checks that there is an NA in the right place and the data-derived truncation value kicks in. This is also checked in

probs_trunc_04_na <- parsnip:::trunc_probs(c(NA, probs), 0.4)
expect_identical(probs_trunc_04_na[1], NA_real_)
expect_equal(probs_trunc_04_na[2], data_derived_trunc)
expect_equal(probs_trunc_04_na[3:6], probs[2:5])

@hfrick hfrick requested a review from topepo May 16, 2023 09:58
@topepo topepo merged commit fe721f6 into main May 17, 2023
@topepo topepo deleted the test-trunc_probs-reduced branch May 17, 2023 01:00
@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 May 31, 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.

2 participants