Tests/test_utils.R

library( cuRious )
library( microbenchmark )

thr <- 10^-6

test.thr.equality <- function( obj1, obj2 ){

  switch(
    obj.type( obj1 ),
    n = {
      all(
        obj1 >= obj2 * ( 1 - thr ),
        obj2 >= obj1 * ( 1 - thr ),
        obj1 <= obj2 * ( 1 + thr ),
        obj2 <= obj1 * ( 1 + thr )
      )
    },
    identical( obj1, obj2 )
  )
}
kajomano/cuRious documentation built on May 14, 2019, 6:14 p.m.