Skip to content

Commit b14fd04

Browse files
authored
fix typo in case weights error message (#989)
1 parent 9afb8b4 commit b14fd04

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

R/case_weights.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ case_weights_allowed <- function(spec) {
7878
if (nrow(model_info) != 1) {
7979
rlang::abort(
8080
glue::glue(
81-
"Error in geting model information for model {mod_type} with engine {mod_eng} and mode {mod_mode}."
81+
"Error in getting model information for model {mod_type} with engine {mod_eng} and mode {mod_mode}."
8282
)
8383
)
8484
}

tests/testthat/_snaps/case-weights.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# case weights with formula method -- unregistered model spec
2+
3+
Code
4+
bag_mars("regression") %>% fit(Sale_Price ~ Longitude + Latitude, data = ames,
5+
case_weights = wts)
6+
Condition
7+
Error in `case_weights_allowed()`:
8+
! Error in getting model information for model bag_mars with engine earth and mode regression.
9+

tests/testthat/test-case-weights.R

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,25 @@ test_that('case weights with formula method', {
110110
expect_equal(coef(lm_wt_fit$fit), coef(lm_sub_fit$fit))
111111
})
112112

113+
test_that('case weights with formula method -- unregistered model spec', {
114+
115+
skip_if_not_installed("modeldata")
116+
data("ames", package = "modeldata")
117+
ames$Sale_Price <- log10(ames$Sale_Price)
118+
119+
set.seed(1)
120+
wts <- runif(nrow(ames))
121+
wts <- ifelse(wts < 1/5, 0L, 1L)
122+
ames_subset <- ames[wts != 0, ]
123+
wts <- frequency_weights(wts)
124+
125+
expect_snapshot(
126+
error = TRUE,
127+
bag_mars("regression") %>%
128+
fit(Sale_Price ~ Longitude + Latitude, data = ames, case_weights = wts)
129+
)
130+
})
131+
113132
test_that('case weights with formula method that goes through `fit_xy()`', {
114133

115134
skip_if_not_installed("modeldata")

0 commit comments

Comments
 (0)