tests/testthat/test-fiting.R

test_that("fit and fit_xy errors if outcome is provided", {
  expect_error(
    k_means(num_clusters = 5) %>% fit_xy(mtcars),
    regexp = NA
  )

  expect_snapshot(
    error = TRUE,
    k_means(num_clusters = 5) %>%
      fit_xy(mtcars, y = mtcars$mpg)
  )

  km <- k_means(num_clusters = 5)

  expect_error(
    workflows::workflow(~., km) %>% fit(mtcars),
    regexp = NA
  )
  expect_snapshot(
    error = TRUE,
    workflows::workflow(mpg ~ ., km) %>% fit(mtcars)
  )
})

Try the tidyclust package in your browser

Any scripts or data that you put into this service are public.

tidyclust documentation built on Sept. 26, 2023, 1:08 a.m.