tests/testthat/test-onehot.R

context("test-onehot.R")

test_that("onehot encoding and decoding", {

  y <- letters[1:4]
  Y <- matrix(c(1, 0, 0, 0,
                0, 1, 0, 0,
                0, 0, 1, 0,
                0, 0, 0, 1),
              byrow = TRUE, ncol = 4)
  colnames(Y) <- y



  expect_identical(Y, onehot(y))
  expect_identical(y, decode_onehot(Y))

  decode <- onehot_with_decoder(y)[[2]]
  expect_identical(y, decode(Y))


})

Try the listarrays package in your browser

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

listarrays documentation built on March 26, 2020, 6:10 p.m.