Skip to content

Commit

Permalink
examples
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] committed Feb 20, 2013
1 parent 3c866bf commit 6ee3823
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
14 changes: 14 additions & 0 deletions examples/mmap_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from annoy import AnnoyIndex

a = AnnoyIndex(3)
a.add_item(0, [1, 0, 0])
a.add_item(1, [0, 1, 0])
a.add_item(2, [0, 0, 1])
a.build(7)
a.save('test.tree')

b = AnnoyIndex(3)
b.load('test.tree')

print b.get_nns_by_item(0, 100)
print b.get_nns_by_vector([1.0, 0.5, 0.5], 100)
10 changes: 10 additions & 0 deletions examples/simple_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from annoy import AnnoyIndex

a = AnnoyIndex(3)
a.add_item(0, [1, 0, 0])
a.add_item(1, [0, 1, 0])
a.add_item(2, [0, 0, 1])
a.build(7)

print a.get_nns_by_item(0, 100)
print a.get_nns_by_vector([1.0, 0.5, 0.5], 100)

0 comments on commit 6ee3823

Please sign in to comment.