tests/testthat/test-math.R

test_that("math functions work", {
  expect_identical(permutate(5L, 1L), 5)
  expect_identical(permutate(5L, 2L), 20)
  expect_identical(permutate(5L, 3L), 60)
  expect_identical(permutate(5L, 4L), factorial(5L))
  expect_identical(probit(0.5), 0)
  expect_identical(logit(c(0, 0.5, 1)), c(-Inf, 0, Inf))
  expect_identical(sigmoid(c(-Inf, 0, Inf)), c(0, 0.5, 1))
  expect_identical(logistic(c(-Inf, 0, Inf)), c(0, 0.5, 1))
  expect_identical(exponent(129.3, 10), 2)
  expect_equal(mantissa(129.3, 10), 1.293, tolerance = 1e-12)
  expect_mapequal(scientific_notation(129.3), c(mantissa = 1.293, exponent = 2))
})
heavywatal/rwtl documentation built on April 29, 2024, 2:02 a.m.