tests/testthat/test_getNullAndPerfectScores.R

library(otsad)
context("Get Null And Perfect Scores")

test_that("GetNullAndPerfectScores gives the correct result", {

  is.real.anomaly <- rep(0,180)
  is.real.anomaly[c(1,50,60,70)] <- 1
  df <- data.frame(timestamp = 1:180, value = 1:180, is.real.anomaly)
  res1 <- GetNullAndPerfectScores(df)

  df2 <- data.frame(timestamp = 1, value = 1:10, is.real.anomaly = rep(0,10))
  res2 <- GetNullAndPerfectScores(df2)

  expect_equal(res1$null.score, c(-4,-4,-8))
  expect_equal(res1$perfect.score, c(4, 4, 4))
  expect_equal(res2$null.score, c(0, 0, 0))
  expect_equal(res2$perfect.score, c(0, 0, 0))

})

Try the otsad package in your browser

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

otsad documentation built on Sept. 6, 2019, 5:02 p.m.