test_that("euc_d returns proper distances", {
a <- 3
b <- 4
expect_equal(euc_d(a,b), 1)
a <- c(0,0)
b <- c(3,4)
expect_equal(euc_d(a,b), 5)
a <- matrix(c(0,0,0,0), nrow = 2)
b <- matrix(c(3,4,4,3), nrow = 2)
expect_equal(euc_d(a,b), c(5,5))
})
test_that("euc_d returns proper warnings", {
a <- 3
b <- c(1,2)
expect_warning(euc_d(a,b), "The two points must have the same dimensions")
a <- matrix(c(1,2,3,4))
b <- c(1,2)
expect_warning(euc_d(a,b), "The two items must be both vectors or matrices")
a <- matrix(c(1,2,3,4))
b <- matrix(c(1,2,3,4), ncol = 2)
expect_warning(euc_d(a,b), "The two matrices must have the same number of columns, representing each of the dimensions of the points they contain")
a <- matrix(c(1,2,3,4,5,6), ncol=2)
b <- matrix(c(1,2,3,4), ncol=2)
expect_warning(euc_d(a,b), "Because the matrices have uneven number of rows, only the distances for the first 2 rows were done")
})
test_that("make_distr_pdf and make_distr6_pdf are equivalent",{
set.seed(1)
mcmc <- sampler_mcmc(make_distr_pdf(distr::Norm()), start = 0, sigma_prop = 1)
set.seed(1)
mcmc2 <- sampler_mcmc(make_distr6_pdf(distr6::Normal$new()), start = 0, sigma_prop = 1)
expect_equal(mcmc, mcmc2)
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.