inst/tinytest/test-in.R

do_par_in_hash_int <- hutilscpp:::do_par_in_hash_int
do_par_in <- hutilscpp:::do_par_in
# test_that("%in% aliases work", {
  a <- 0:10
  b <- 0:5
  expect_identical(do_par_in_hash_int(a, b), a %in% b)
  expect_identical(do_par_in_hash_int(b, a), b %in% a)

  e <- c(40L, 50L, 43L, 21L, 20L, 27L, 1L, 12L, 48L, 47L, 30L, 31L,
         24L, 16L, 5L, 34L, 37L, 22L, 29L, 28L)
  f <- c(36L, 20L, 41L, 40L)
  expect_identical(do_par_in(e, f), e %in% f)
  expect_identical(do_par_in_hash_int(e, f), e %in% f)
if (at_home()) {


  expect_identical(do_par_in(e, f, nThread = 2L), e %in% f)
  expect_identical(do_par_in_hash_int(e, f, nThread = 2L), e %in% f)
  rm(e, f)

  ee <- c(-976989192L, -653207067L, 975583360L, 2118375408L, -785341338L,
          -901562950L, -1727139124L, -207603946L, -2111382195L, -644083675L,
          1536746242L, 47364314L, 1031464972L, -204441187L, -92642247L,
          1201681761L, 1123068454L, -1971926251L, -940253143L, 253830767L,
          770071173L, 643746361L, -503975934L, 137197379L, -181253826L,
          -1091649788L, 1456735194L, 1769964474L, -1321599313L, 1631768701L,
          468520608L, 1123466200L, 799207517L, -1599117672L, -1292328289L,
          -1764209640L, -1865293046L, 439850498L, 318585044L, 275230292L,
          427917307L, -923220950L, -2102632547L, -1943493815L, 496144287L,
          1827958308L, 1074323427L, 898551405L, -558753678L, -476651190L)
  ff <-
    c(746007105L, -1077508854L, -1550612969L, 1270083952L, 1078447319L,
      -180114029L, 246509131L, 1737015014L, 965096937L, -1802217995L,
      -1329290765L, -2039206074L, 558218219L, 874182617L, -2005349705L,
      -1935177894L, 645426666L, 1986679330L, 1026617001L, 1918976149L,
      -33798925L, -249870231L, -1485632862L, 1621182130L, 819545964L,
      1483729845L, -1548148278L, -2112766573L, -630314559L, -1093298508L,
      525131640L, 1217193708L, 1115241204L, 775995074L, 2064919314L,
      -2119310185L, -1228301412L, 1112900262L, -731243537L, -713358508L,
      656728730L, 512400948L, 816766980L, -1421944909L, -701386658L,
      1739404998L, -2123260410L, 537514530L, -766144651L, -1618787392L,
      1199986648L, 1141650700L, -47343737L, 8418151L)

  expect_identical(do_par_in(ee, ff), ee %in% ff)
  expect_identical(do_par_in_hash_int(ee, ff), ee %in% ff)

  ee <- c(ee, ff[2])
  expect_true(any(do_par_in_hash_int(ee, ff)))

}

Try the hutilscpp package in your browser

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

hutilscpp documentation built on Oct. 11, 2023, 9:06 a.m.