tests/testthat/test-surround_set.R

test_that("surround_set samples sphere of correct distance", {
  eucl <- function(set, ref) sqrt(sum((set-ref)^2))
  base <- c(0, 3, 7)
  expect_equal(fpunique(apply(surround_set(base, 
                                           magnitude=0.5), 
                              2, eucl, ref=base)), 
               1)
  expect_equal(fpunique(apply(surround_set(base, 
                                           magnitude=0.5,
                                           distance=2/3), 
                              2, eucl, ref=base)), 
               2/3)
})

test_that("surround_set returns matrix of appropriate size", {
  expect_equal(dim(surround_set(c(0,2,6,9), magnitude=1))[1], 4)
  expect_equal(dim(surround_set(c(0,2,6,9), magnitude=1))[2], 40)
})

Try the musicMCT package in your browser

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

musicMCT documentation built on June 21, 2026, 9:06 a.m.