tests/testthat/test-spectraMaths.R

test_that("Addition and subtraction works as expected", {
  wn <- tuneR::noise("white")
  wns <- seewave::spec(wn, plot=FALSE)
  expect_equal(wns, addSpectra(wns, zeroSpectrum(wns)))
  expect_equal(wns[,2]*2, addSpectra(wns, wns)[,2])
  expect_equal(wns[,2], subtractSpectra(wns, zeroSpectrum(wns))[,2])
})

test_that("normalise Spectra works", {
  wn <- tuneR::noise("white")
  wns <- seewave::spec(wn, plot=FALSE)
  wns[1,2] <- 42
  wnsn <- normaliseSpectrum(wns)
  expect_equal(max(wnsn[,2]), 1)
})

Try the sonicscrewdriver package in your browser

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

sonicscrewdriver documentation built on May 29, 2024, 3:39 a.m.