File: test-common_subtrees.R

package info (click to toggle)
r-cran-dendextend 1.14.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 2,888 kB
  • sloc: sh: 13; makefile: 2
file content (52 lines) | stat: -rw-r--r-- 970 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# library(testthat)
suppressPackageStartupMessages(library(dendextend))

context("common subtrees")


test_that("rank_values_with_clusters works", {
  expect_equal(
    rank_values_with_clusters(c(1, 2, 3)),
    1:3
  )

  expect_equal(
    rank_values_with_clusters(c(1, 1, 3)),
    c(1L, 1L, 2L)
  )

  expect_equal(
    rank_values_with_clusters(c(0.1, 0.1, 3000)),
    c(1L, 1L, 2L)
  )

  expect_equal(
    rank_values_with_clusters(c(3, 1, 2)),
    1:3
  )
  #
  expect_equal(
    rank_values_with_clusters(c(1, 3, 3, 3, 3, 3, 3, 4, 2, 2)),
    c(1L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 4L, 4L)
  )

  expect_equal(
    rank_values_with_clusters(c(3, 1, 2), ignore0 = TRUE),
    1:3
  )

  expect_equal(
    rank_values_with_clusters(c(3, 1, 2), ignore0 = FALSE),
    1:3
  )

  expect_equal(
    rank_values_with_clusters(c(3, 1, 0, 2), ignore0 = TRUE),
    c(1, 2, 0, 3)
  )

  expect_equal(
    rank_values_with_clusters(c(3, 1, 0, 2), ignore0 = FALSE),
    1:4
  )
})