tests/testthat/test-vorob.R

context("vorob")
library(eaf)

test_that("vorob", {
  #skip_on_cran()
  test_data <- expand.grid(seq(0, 1, length.out = 51),
                           seq(0, 1, length.out = 51))
  test_data <- as.matrix(cbind(test_data, nrun = 1:nrow(test_data)))
  
  # Average hypervolume is known to be 0.25
  # avg_hyp <- mean(sapply(split.data.frame(test_data[,1:2], test_data[,3]),
  #                        hypervolume, reference = c(1, 1))) 
  expect_equal(hypervolume(vorobT(x = test_data, reference = c(1, 1))$VE, reference = c(1, 1)), 0.25, tolerance = 1e-1)
  
  expect_equal(vorobDev(x = test_data, VE = vorobT(test_data, c(1,1))$VE, reference = c(1, 1)), 0.218, tolerance = 1e-1)

})

Try the eaf package in your browser

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

eaf documentation built on March 31, 2023, 9:08 p.m.