tests/testthat/test-rank_conversion.R

test_that("create_ranking returns correct values", {
  orderings <- matrix(c(1, 2, 2, 3, 3, 1), ncol = 3)
  rankings <- matrix(c(1, 3, 2, 1, 3, 2), ncol = 3)
  expect_equal(create_ranking(orderings), rankings)
  orderings[2, 2] <- NA_real_
  rankings[2, 3] <- NA_real_
  expect_equal(create_ranking(orderings), rankings)
  orderings[2, 3] <- NA_real_
  rankings[2, 1] <- NA_real_
  expect_equal(create_ranking(orderings), rankings)
})


test_that("create_orderings returns correct values", {
  orderings <- matrix(c(1, 2, 2, 3, 3, 1), ncol = 3)
  rankings <- matrix(c(1, 3, 2, 1, 3, 2), ncol = 3)
  expect_equal(create_ordering(rankings), orderings)
  orderings[2, 2] <- NA_real_
  rankings[2, 3] <- NA_real_
  expect_equal(create_ordering(rankings), orderings)
  orderings[2, 3] <- NA_real_
  rankings[2, 1] <- NA_real_
  expect_equal(create_ordering(rankings), orderings)
})

Try the BayesMallows package in your browser

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

BayesMallows documentation built on Sept. 11, 2024, 5:31 p.m.