summaryrefslogtreecommitdiff
path: root/math/py-annoy/files/test-save.py
diff options
context:
space:
mode:
authorYuri Victorovich <yuri@FreeBSD.org>2023-01-11 21:24:48 -0800
committerYuri Victorovich <yuri@FreeBSD.org>2023-01-11 21:25:23 -0800
commitc5c128b186be0150e2d4885d9dde759fc93b25c9 (patch)
treecf59959ddf6923cd98a71fde122f60eef9b033eb /math/py-annoy/files/test-save.py
parentmath/annoy: New port: Approximate Nearest Neighbors in C++ (diff)
math/py-annoy: New port: Approximate Nearest Neighbors in C++
Diffstat (limited to 'math/py-annoy/files/test-save.py')
-rw-r--r--math/py-annoy/files/test-save.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/math/py-annoy/files/test-save.py b/math/py-annoy/files/test-save.py
new file mode 100644
index 000000000000..21a8f50df0c0
--- /dev/null
+++ b/math/py-annoy/files/test-save.py
@@ -0,0 +1,12 @@
+from annoy import AnnoyIndex
+import random
+
+f = 40 # Length of item vector that will be indexed
+
+t = AnnoyIndex(f, 'angular')
+for i in range(1000):
+ v = [random.gauss(0, 1) for z in range(f)]
+ t.add_item(i, v)
+
+t.build(10) # 10 trees
+t.save('test.ann')