Skip to content

Commit

Permalink
Merge pull request #7 from erikbern/erikbern/tox
Browse files Browse the repository at this point in the history
setting up travis
  • Loading branch information
erikbern committed Jun 20, 2015
2 parents 0e14d70 + e58e4af commit fd2ceb3
Show file tree
Hide file tree
Showing 12 changed files with 154 additions and 83 deletions.
9 changes: 9 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
language: python
python:
- "2.7_with_system_site_packages"
- "3.4"

install:
- sudo bash install.sh

script: nosetests
4 changes: 3 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ Doing fast searching of nearest neighbors in high dimensional spaces is an incre
Install
-------

Clone the repo and run ``bash install.sh``. This will install all libraries as well as downloading and preprocessing all data sets. It could take a while. It has been tested in Ubuntu 14.04.
Clone the repo and run ``bash install.sh``. This will install all libraries. It could take a while. It has been tested in Ubuntu 14.04.

To download and preprocess the data sets, run ``bash install/glove.sh`` and ``bash install/sift.sh``.

There is also a Docker image available under `erikbern/ann <https://registry.hub.docker.com/u/erikbern/ann/>`__ containing all libraries and data sets.

Expand Down
160 changes: 89 additions & 71 deletions ann_benchmarks.py → ann_benchmarks/__init__.py

Large diffs are not rendered by default.

13 changes: 11 additions & 2 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
sudo apt-get install -y python-numpy python-scipy python-sklearn
apt-get update
apt-get install -y python-numpy python-scipy python-pip python-nose
pip install scikit-learn

# Install GCC 4.8
add-apt-repository ppa:ubuntu-toolchain-r/test -y
apt-get update -qq
apt-get install -y libboost1.48-all-dev g++-4.8
export CXX="g++-4.8" CC="gcc-4.8"

cd install
for fn in annoy.sh panns.sh nearpy.sh sklearn.sh flann.sh kgraph.sh nmslib.sh glove.sh sift.sh
for fn in annoy.sh panns.sh nearpy.sh sklearn.sh flann.sh kgraph.sh nmslib.sh
do
source $fn
done
4 changes: 2 additions & 2 deletions install/annoy.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
sudo apt-get install -y python-dev python-setuptools
apt-get install -y python-dev python-setuptools
git clone https://github.com/spotify/annoy
cd annoy
sudo python setup.py install
python setup.py install
cd ..
1 change: 1 addition & 0 deletions install/glove.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
cd "$(dirname "$0")"
wget "http://www-nlp.stanford.edu/data/glove.twitter.27B.100d.txt.gz"
gunzip -d glove.twitter.27B.100d.txt.gz
cut -d " " -f 2- glove.twitter.27B.100d.txt > glove.txt # strip first column
Expand Down
1 change: 1 addition & 0 deletions install/kgraph.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
git clone https://github.com/aaalgo/kgraph
pushd kgraph
apt-get install -y libboost-timer-dev libbooost-chrono-dev
sudo make deps-ubuntu
make
make release
Expand Down
5 changes: 3 additions & 2 deletions install/nearpy.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
sudo apt-get install -y python-pip
sudo pip install nearpy bitarray redis
apt-get install -y python-pip libhdf5-dev
pip install cython
pip install nearpy bitarray redis h5py
9 changes: 4 additions & 5 deletions install/nmslib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ rm -rf NonMetricSpaceLib
# Note that we use the develop branch here:
git clone https://github.com/searchivarius/NonMetricSpaceLib.git
cd NonMetricSpaceLib/similarity_search
git checkout ann-benchmark
sudo apt-get install -y cmake libeigen3-dev libgsl0-dev libboost-all-dev g++-4.8
# Actually let's make g++ an alias
alias g++=g++-4.8
git checkout ann-benchmark
apt-get install -y cmake libeigen3-dev libgsl0-dev libboost-all-dev
echo "CC: $CC, CXX: $CXX"
cmake .
make -j 4
cd ../python_binding
make
sudo make install
make install
cd ../..
1 change: 1 addition & 0 deletions install/sift.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
cd "$(dirname "$0")"
wget "ftp://ftp.irisa.fr/local/texmex/corpus/sift.tar.gz"
tar -xzf sift.tar.gz
rm -rf sift.tar.gz
Expand Down
3 changes: 3 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from setuptools import setup

setup(packages=['ann_benchmarks'])
27 changes: 27 additions & 0 deletions test/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import random
import inspect
import ann_benchmarks
from sklearn.datasets.samples_generator import make_blobs

# Generate dataset
X, labels_true = make_blobs(n_samples=10000, n_features=10,
centers=10, cluster_std=5,
random_state=0)

def check_algo(algo_name, algo):
algo.fit(X)
result = algo.query(X[42], 10)
if len(result) != 10:
raise AssertionError('Expected results to have length 10: Result: %s' % result)
if len(set(result)) != 10:
raise AssertionError('Expected results to be unique: Result: %s' % result)
#if result[0] != 42:
# raise AssertionError('Expected first item to be 42: Result: %s' % result)


def test_all_algos():
for metric in ['angular', 'euclidean']:
algos = ann_benchmarks.get_algos(metric)
for algo_key in algos.keys():
algo = random.choice(algos[algo_key]) # Just pick one of each
yield check_algo, algo.name, algo # pass name just so unittest can capture it

0 comments on commit fd2ceb3

Please sign in to comment.