File: test_get_knn.R

package info (click to toggle)
r-cran-rcpphnsw 0.3.0.9001%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 316 kB
  • sloc: cpp: 386; ansic: 58; sh: 13; makefile: 2
file content (16 lines) | stat: -rw-r--r-- 636 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
library(RcppHNSW)
context("hnsw_knn")

res <- hnsw_knn(ui10, k = 4)
expect_equal(res$idx, self_nn_index4, check.attributes = FALSE)
expect_equal(res$dist, self_nn_dist4, check.attributes = FALSE, tol = 1e-6)

res <- hnsw_knn(ui10, k = 4, distance = "l2")
expect_equal(res$idx, self_nn_index4, check.attributes = FALSE)
expect_equal(res$dist, self_nn_dist4^2, check.attributes = FALSE, tol = 1e-6)

res <- hnsw_knn(ui10, k = 1)
expect_is(res$idx, "matrix")
expect_is(res$dist, "matrix")
expect_equal(res$idx, self_nn_index4[, 1], check.attributes = FALSE)
expect_equal(res$dist, self_nn_dist4[, 1], check.attributes = FALSE, tol = 1e-6)