Skip to content

Merge pypi package changes to master #144

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Aug 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ language: python
matrix:
include:
- python: 3.6
- python: 3.7
install:
- |
cd python_bindings
Expand All @@ -12,4 +13,4 @@ install:
script:
- |
cd python_bindings
python setup.py test
python setup.py test
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Hnswlib - fast approximate nearest neighbor search
Header-only C++ HNSW implementation with python bindings. Paper code for the HNSW 200M SIFT experiment

**NEWS:**

**Thanks to Louis Abraham ([@louisabraham](https://github.com/louisabraham)) hnswlib is now can be installed via pip!**

Highlights:
1) Lightweight, header-only, no dependencies other than C++ 11.
2) Interfaces for C++, python and R (https://github.com/jlmelville/rcpphnsw).
Expand All @@ -26,7 +30,7 @@ Note that inner product is not an actual metric. An element can be closer to som

For other spaces use the nmslib library https://github.com/nmslib/nmslib.

#### short API description
#### Short API description
* `hnswlib.Index(space, dim)` creates a non-initialized index an HNSW in space `space` with integer dimension `dim`.

Index methods:
Expand All @@ -45,7 +49,7 @@ Index methods:
* `resize_index(new_size)` - changes the maximum capacity of the index. Not thread safe with `add_items` and `knn_query`.

* `set_ef(ef)` - sets the query time accuracy/speed trade-off, defined by the `ef` parameter (
[ALGO_PARAMS.md](ALGO_PARAMS.md)).
[ALGO_PARAMS.md](ALGO_PARAMS.md)). Note that the parameter is currently not saved along with the index, so you need to set it manually after loading.

* `knn_query(data, k = 1, num_threads = -1)` make a batch query for `k` closests elements for each element of the
* `data` (shape:`N*dim`). Returns a numpy array of (shape:`N*k`).
Expand Down Expand Up @@ -166,13 +170,18 @@ print("Recall for two batches:", np.mean(labels.reshape(-1) == np.arange(len(dat
```

### Bindings installation

You can install from sources:
```bash
apt-get install -y python-setuptools python-pip
pip3 install pybind11 numpy setuptools
cd python_bindings
python3 setup.py install
```

or you can install via pip:
`pip install hnswlib`

### Other implementations
* Non-metric space library (nmslib) - main library(python, C++), supports exotic distances: https://github.com/nmslib/nmslib
* Faiss libary by facebook, uses own HNSW implementation for coarse quantization (python, C++):
Expand Down
1 change: 1 addition & 0 deletions python_bindings/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include hnswlib/*.h
14 changes: 14 additions & 0 deletions python_bindings/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
pypi: dist
twine upload dist/*

dist:
-rm dist/*
python3 setup.py sdist

test:
python3 setup.py test

clean:
rm -rf *.egg-info build dist var first_half.bin tests/__pycache__ hnswlib.cpython-36m-darwin.so

.PHONY: dist
2 changes: 1 addition & 1 deletion python_bindings/bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <pybind11/pybind11.h>
#include <pybind11/numpy.h>
#include <pybind11/stl.h>
#include "../hnswlib/hnswlib.h"
#include "hnswlib/hnswlib.h"
#include <thread>
#include <atomic>

Expand Down
1 change: 1 addition & 0 deletions python_bindings/hnswlib