hannoy 0.2.0

HNSW Approximate Nearest Neighbors in Rust, based on LMDB and optimized for memory usage
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
from pathlib import Path

import pytest

import hannoy
from hannoy import Metric


@pytest.fixture(scope="function")
def db(tmp_path: Path):
    db = hannoy.Database(tmp_path, Metric.HAMMING)

    with db.writer(3, m=4, ef=10) as writer:
        writer.add_item(0, [1.0, 0.0, 0.0])
        writer.add_item(1, [0.0, 1.0, 0.0])
        writer.add_item(2, [0.0, 0.0, 1.0])

    yield db